Skip to content

Commit eb0a586

Browse files
committed
fix: menubar no longer automatically focused when page first loads
1 parent bbfb237 commit eb0a586

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client/components/Menubar/Menubar.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function Menubar({ children, className }) {
150150

151151
const handleBlur = useCallback(
152152
(e) => {
153-
const isInMenu = nodeRef.current?.contains(e.relatedTarget);
153+
const isInMenu = nodeRef.current?.contains(document.activeElement);
154154

155155
if (!isInMenu) {
156156
timerRef.current = setTimeout(() => {
@@ -206,7 +206,10 @@ function Menubar({ children, className }) {
206206
// roving tabindex
207207
prevNode?.setAttribute('tabindex', '-1');
208208
activeNode?.setAttribute('tabindex', '0');
209-
activeNode?.focus();
209+
210+
if (hasFocus) {
211+
activeNode?.focus();
212+
}
210213
}
211214
}, [activeIndex, prevIndex, menuItems]);
212215

0 commit comments

Comments
 (0)