Repository navigation
Replace ember-modal-dialog with native <dialog> and Popover API - #1710
andreisebastianc wants to merge 1 commit into
Conversation
ember-modal-dialog (and its ember-tether/ember-wormhole dependencies) is unmaintained and blocks upgrading consuming apps. The three places that used it now rely on browser primitives instead: - Search results and the version selector are `popover="manual"` elements rendered in the top layer and placed next to their anchor with CSS anchor positioning (`position-anchor` / `position-area`, with `@position-try` fallbacks that pin to the viewport edge or flip, like ember-tether's "pin" constraint did). Browsers that support popovers but not anchor positioning (Safari 17/18, Firefox < 147) fall back to inline top/left styles computed from the anchor's bounding box. - The keyboard shortcuts modal is a native `<dialog>` opened with `showModal()`: the browser provides the backdrop, focus trapping, inert page content, Escape handling and (where supported) light dismiss via `closedby="any"`; a click-on-backdrop fallback covers older browsers. Behavioural fixes that came with this: - A long list of versions now scrolls inside the dropdown instead of running off the bottom of the viewport. - Clicking the search input no longer closes the results and clears the query (the old click-outside handler did not exclude the anchor). - Escape closes the version selector. - The dialog close control is a <button> instead of an `href="#"` link, and the page behind the open dialog no longer scrolls. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
What's this: I use ember-cli-addon-docs at my workplace. For a long time, it's been clear to me that the addon will have trouble moving to newer ember versions because of several abandoned addons like ember-modal-dialog. I think simply inlining the addon code is not a good idea, even if other deprecated addons like ember-tether would be inlined at the same time. I've made sure to use modifiers instead of This implementation maintains feature parity, for better or worse. P.S.:
|
|
nice!!!!! |
There was a problem hiding this comment.
🟡 Changes recommended
Unconditional flex styling leaves closed popovers visible, with additional unresolved defects in dialog dismissal, focus restoration, and keyboard-selected search result visibility.
4 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Replaces the documentation UI’s unmaintained modal dependencies with native browser features, removing a blocker for consuming-app upgrades.
Changes:
- Uses anchored popovers for search results and version selection, with positioning fallbacks and internal scrolling.
- Moves keyboard shortcuts to a native dialog with modal focus handling, backdrop dismissal, and scroll locking.
- Removes legacy dependencies and adds interaction, layout, and lifecycle tests.
| File | Description |
|---|---|
tests/integration/modifiers/docs-popover-test.js |
Tests popover lifecycle and dismissal. |
tests/integration/modifiers/docs-dialog-test.js |
Tests modal opening and close callbacks. |
tests/dummy/config/environment.js |
Removes obsolete tether configuration. |
tests/acceptance/version-selector-test.js |
Tests dropdown positioning, dismissal, and scrolling. |
tests/acceptance/search-test.js |
Tests search popover layout and interactions. |
tests/acceptance/keyboard-shortcuts-test.js |
Adds native dialog acceptance tests. |
pnpm-workspace.yaml |
Removes modal dependency build permission. |
pnpm-lock.yaml |
Updates the resolved dependency graph. |
package.json |
Replaces modal dependencies with ember-modifier. |
app/modifiers/docs-popover.js |
Exposes the popover modifier. |
app/modifiers/docs-dialog.js |
Exposes the dialog modifier. |
app/components/docs-modal-dialog.js |
Removes the legacy component re-export. |
addon/styles/components/_modal-dialog.scss |
Removes legacy modal styling. |
addon/styles/components/_docs-popover.scss |
Adds anchored placement and scrolling styles. |
addon/styles/components/_docs-keyboard-shortcuts.scss |
Styles the native dialog and backdrop. |
addon/styles/addon.scss |
Replaces the legacy modal stylesheet import. |
addon/modifiers/docs-popover.js |
Manages popover setup and teardown. |
addon/modifiers/docs-dialog.js |
Handles modal opening and dismissal callbacks. |
addon/components/docs-modal-dialog.js |
Removes the legacy modal wrapper. |
addon/components/docs-keyboard-shortcuts/index.js |
Updates the dialog dismissal action. |
addon/components/docs-keyboard-shortcuts/index.hbs |
Uses a native dialog and close button. |
addon/components/docs-header/version-selector/index.hbs |
Converts version selection to a popover. |
addon/components/docs-header/search-results/index.hbs |
Converts search results to a popover. |
addon/components/docs-header/index.hbs |
Identifies the version selector trigger. |
addon/-private/popover.js |
Adds shared positioning and dismissal logic. |
Review effort: Balanced
| background: transparent; | ||
| color: inherit; | ||
| overflow: visible; | ||
| display: flex; |
|
|
||
| constructor(owner, args) { | ||
| super(owner, args); | ||
| registerDestructor(this, () => this._removeListeners?.()); |
| // A click whose target is the <dialog> element itself landed on its | ||
| // ::backdrop, i.e. outside the dialog box. | ||
| let handleClick = (event) => { | ||
| if (event.target === dialog) { | ||
| onClose(); | ||
| } | ||
| }; |
|
|
||
| > * { | ||
| min-height: 0; | ||
| overflow-y: auto; |


















ember-modal-dialog (and its ember-tether/ember-wormhole dependencies) is unmaintained and blocks upgrading consuming apps. The three places that used it now rely on browser primitives instead:
popover="manual"elements rendered in the top layer and placed next to their anchor with CSS anchor positioning (position-anchor/position-area, with@position-tryfallbacks that pin to the viewport edge or flip, like ember-tether's "pin" constraint did). Browsers that support popovers but not anchor positioning (Safari 17/18, Firefox < 147) fall back to inline top/left styles computed from the anchor's bounding box.<dialog>opened withshowModal(): the browser provides the backdrop, focus trapping, inert page content, Escape handling and (where supported) light dismiss viaclosedby="any"; a click-on-backdrop fallback covers older browsers.Behavioural fixes that came with this:
href="#"link, and the page behind the open dialog no longer scrolls.