Skip to content

How to reset previous focus when moving away from Menu #3635

Answered by diegohaz
bengry asked this question in Questions
Discussion options

You must be logged in to vote

That's typically how composite widgets like menubar and tablist work. Though you can reset the activeId state on blur if necessary:

const store = useMenubarStore();

<Menubar
  store={store}
  onBlur={(event) => {
    // ignore blur events inside the menubar
    if (event.currentTarget.contains(event.relatedTarget)) return;
    // reset the active item id
    store.setActiveId(undefined);
  }}

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@bengry
Comment options

@diegohaz
Comment options

@bengry
Comment options

@diegohaz
Comment options

Answer selected by bengry
@bengry
Comment options

@diegohaz
Comment options

@bengry
Comment options

@diegohaz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants