Skip to content

Commit 35109b5

Browse files
committed
fix(web): replace timed scope-change guard with one-shot flag
The 500ms suppression window could in principle swallow a legitimate filter selection. Suppress exactly one scope change instead, clearing the flag whenever the menu reopens: a real selection always starts by reopening the menu, so only the Safari ghost click after Ctrl+click can ever be suppressed.
1 parent 193bc84 commit 35109b5

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,13 +1883,15 @@ export default function Sidebar() {
18831883
// On macOS, Ctrl+click fires contextmenu and Safari then also fires click on
18841884
// the same element, which would activate the radio item and change the scope
18851885
// underneath the settings page. stopPropagation on contextmenu cannot block
1886-
// that separate click, so scope changes are suppressed briefly instead.
1887-
const projectSettingsInvokedAtRef = useRef(0);
1886+
// that separate click, so the next scope change is suppressed instead. The
1887+
// flag clears when the menu reopens, and a real selection always starts by
1888+
// reopening the menu, so it can never swallow one.
1889+
const suppressNextScopeChangeRef = useRef(false);
18881890
const handleProjectSettings = useCallback(
18891891
(event: ReactMouseEvent<HTMLElement>, projectGroup: SidebarProjectSnapshot) => {
18901892
event.preventDefault();
18911893
event.stopPropagation();
1892-
projectSettingsInvokedAtRef.current = Date.now();
1894+
suppressNextScopeChangeRef.current = true;
18931895
setProjectScopeMenuOpen(false);
18941896
if (isMobile) {
18951897
setOpenMobile(false);
@@ -3335,7 +3337,13 @@ export default function Sidebar() {
33353337
</div>
33363338
{projectGroups.length > 0 ? (
33373339
<div className="flex items-center gap-1">
3338-
<Menu open={projectScopeMenuOpen} onOpenChange={setProjectScopeMenuOpen}>
3340+
<Menu
3341+
open={projectScopeMenuOpen}
3342+
onOpenChange={(open) => {
3343+
if (open) suppressNextScopeChangeRef.current = false;
3344+
setProjectScopeMenuOpen(open);
3345+
}}
3346+
>
33393347
<MenuTrigger
33403348
render={
33413349
<SidebarMenuButton
@@ -3363,7 +3371,10 @@ export default function Sidebar() {
33633371
<MenuRadioGroup
33643372
value={projectScopeKey ?? "all"}
33653373
onValueChange={(value) => {
3366-
if (Date.now() - projectSettingsInvokedAtRef.current < 500) return;
3374+
if (suppressNextScopeChangeRef.current) {
3375+
suppressNextScopeChangeRef.current = false;
3376+
return;
3377+
}
33673378
setProjectScopeKey(value === "all" ? null : (value as string));
33683379
}}
33693380
>

0 commit comments

Comments
 (0)