@fluentui/web-components: fluent-menu-list loses its arrow keys after it is moved in the DOM (Firefox, Safari)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript, web-dev
- Domain
- accessibility, frontend
Research direction
The issue identifies the behavior in menu-list.js: disconnectedCallback() disconnects the focus group, while setItems() reuses it after reconnection. Read those methods and the focus group lifecycle described in the issue, then reproduce the DOM move in Firefox or Safari. Done when ArrowDown moves focus through the menu items after the move, as it does without the move.
Written by the indexing model from the issue text.
Description
Version: @fluentui/web-components 3.1.3, @microsoft/focusgroup-polyfill 1.6.0. Engines: Firefox 153 and WebKit 26.6 (Playwright's builds) fail; Chromium 153 passes, because it has native focusgroup and the polyfill stands aside.
Summary
A fluent-menu-list builds its focus group (the polyfill that gives the arrow keys in an engine without native focusgroup) on its first setItems(), disconnects it when the list leaves the document, and never builds another. Any DOM move, which disconnects and reconnects the element (for example insertBefore, or a framework reordering a list), leaves a menu whose arrow keys do nothing: focus stays on the first item, so Enter chooses the first item whatever the user wanted.
Reproduction
<!doctype html>
<div id="host">
<fluent-menu>
<fluent-button slot="trigger">Actions</fluent-button>
<fluent-menu-list>
<fluent-menu-item>One</fluent-menu-item>
<fluent-menu-item>Two</fluent-menu-item>
<fluent-menu-item>Three</fluent-menu-item>
</fluent-menu-list>
</fluent-menu>
</div>
<script type="module">
import '@fluentui/web-components/button.js';
import '@fluentui/web-components/menu.js';
import '@fluentui/web-components/menu-list.js';
import '@fluentui/web-components/menu-item.js';
// Move the menu in place once, as a framework's reorder would.
const menu = document.querySelector('fluent-menu');
customElements.whenDefined('fluent-menu-list').then(() => menu.parentElement.insertBefore(menu, menu.nextSibling));
</script>
- Open the page in Firefox or Safari. Tab to "Actions" and press Enter: the menu opens with focus on "One".
- Press ArrowDown twice.
- Expected: focus on "Three" (as without the move, and as in Chrome). Actual: focus stays on "One".
The standalone page above reproduces it as written (bundled with esbuild, served to each engine): never moved, "One", "Two", "Three" in all three engines; moved in place once, "One", "Two", "Three" in Chromium and "One", "One", "One" in Firefox and WebKit.
Cause
node_modules/@fluentui/web-components/dist/esm/menu-list/menu-list.js:15-18:disconnectedCallback()callsthis.fg?.disconnect(), and keepsthis.fg.menu-list.js:19-34:setItems()creates theFocusGrouponlyif (!this.fg); otherwise it callsthis.fg.update().node_modules/@microsoft/focusgroup-polyfill/build/focusgroup-shadowless.mjs:101-114: the constructor adds thekeydown,focusinandfocusoutlisteners, once;:127-132:disconnect()aborts them and sets the owner tonull;update()returns at once when there is no owner (:146).
So after a reconnection setItems() "updates" a disconnected group, which does nothing.
Suggested fix
Drop the group when disconnecting (this.fg?.disconnect(); this.fg = undefined;), so the next setItems() builds a new one; or build the group in connectedCallback.
- Dominant language
- TypeScript
- Stars
- 20.3k
- Forks
- 2.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 72
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/fluentui
-
[Bug]: Vertical Slider still logs the deprecated 'slider-vertical' warning in Chromium 132+Possibly taken @jakesalvesen claimed this 1 day ago. OpenFluent UI react-components (v9) Needs: Triage :mag: Type: Bug :bug:
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/fluentui#36945 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[Feature]: export getHashCode for Avatar from avatar.ts for Fluentv8 PersonaInitialsColor / PersonaCoin supportPossibly taken @ValentinaKozlova claimed this 21 days ago. OpenComponent: Avatar Fluent UI react-components (v9) From Shield Needs: Backlog review Type: Feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/fluentui#36802 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug]: WeeklyDayPicker showing incorrect week number when navigating to different weeksPossibly taken @Sanjays2402 claimed this 40 days ago. OpenComponent: CalendarDayGrid Component: WeeklyDayPicker Fluent UI react (v8) Type: Bug :bug:
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/fluentui#36721 · 2 comments ·
Maintainers usually reply within 1 day
All issues in microsoft/fluentui
Similar issues
-
check:passed streams:edit
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:mcp bug has repro platform:vscode regression
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anthropics/claude-code#103970 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build contextOpenbug javascript
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day