Skip to content

fix: prevent custom event and tooltip errors - #5189

Merged
Denis Voituron (dvoituron) merged 3 commits into
microsoft:dev-v5from
JamesNK:fix/dotnet-11-custom-events
Aug 22, 2026
Merged

Denis Voituron (dvoituron) merged 3 commits into
microsoft:dev-v5from
JamesNK:fix/dotnet-11-custom-events

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

Pull Request

📖 Description

Removes the need for the application-level startup workaround used with Fluent UI Blazor 5.0.0-rc.5:

  • Registers each Fluent custom event once through the existing global registration state, preventing duplicate registration when Blazor Web and Server startup hooks both run.
  • Maps the Blazor overflowchange custom event to a distinct internal fluentoverflowchange browser event, as required by .NET 11.
  • Continues dispatching the public overflowchange DOM event for JavaScript consumers.
  • Overrides showPopover() only for fluent-tooltip so a delayed tooltip callback is ignored after the element has been disconnected. This avoids Chromium's invalid-state exception without modifying HTMLElement.prototype globally.

The failures were found while running Fluent UI Blazor with Native AOT on .NET 11 in microsoft/aspire#19565.

🎫 Issues

Related to #4626.

👩‍💻 Reviewer Notes

Please focus on the dual overflow event dispatch and the global defineOnce registration key. The public Blazor event remains overflowchange, and the documented DOM event remains available; fluentoverflowchange is an internal bridge event.

The tooltip override intentionally delegates to the original fluent-tooltip showPopover implementation only while the tooltip remains connected.

📑 Test Plan

  • npm run build
  • node ./esbuild.config.mjs --build-mode=Release
  • git diff --check
  • Confirmed no TypeScript diagnostics in the changed files.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

⏭ Next Steps

No follow-up work is currently required.

@JamesNK

Copy link
Copy Markdown
Member Author

Javier Calvarro Nelson (@javiercn) This was found while running Fluent UI Blazor v5 with Native AOT on .NET 11 in microsoft/aspire#19565.

@JamesNK

Copy link
Copy Markdown
Member Author

Please manual test before merging. I've just made suggested changes by AI, I haven't done any manual testing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Core.Scripts startup/runtime wiring to avoid .NET 11 Blazor custom-event registration failures and to prevent tooltip popover callbacks from throwing after the element is removed from the DOM.

Changes:

  • Ensures Fluent custom events are registered only once globally (even if both Web and Server startup hooks run).
  • Bridges Blazor’s overflowchange custom event to an internal fluentoverflowchange browser event while still dispatching the public overflowchange DOM event.
  • Overrides fluent-tooltip’s showPopover() to no-op when the tooltip is disconnected, avoiding Chromium invalid-state exceptions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core.Scripts/src/FluentUIWebComponentsOverride.ts Adds a fluent-tooltip showPopover override that ignores stale callbacks after disconnect.
src/Core.Scripts/src/FluentUICustomEvents.ts Wraps registerCustomEventType with global defineOnce and remaps Overflow’s browser event name to fluentoverflowchange.
src/Core.Scripts/src/Components/Overflow/FluentOverflow.ts Dispatches both overflowchange and fluentoverflowchange events with identical payloads.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Core.Scripts/src/FluentUIWebComponentsOverride.ts Outdated
Comment thread src/Core.Scripts/src/FluentUIWebComponentsOverride.ts
@dvoituron
Denis Voituron (dvoituron) merged commit c813a4a into microsoft:dev-v5 Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants