sp-overlay

Examples API Changelog

Events #

Name Type Description slottable-request Event requests to add or remove slottable content sp-closed Event announce that an overlay has compelted any exit animations sp-opened Event announces that an overlay has completed any entry animations

1.0.1 (2024-11-11) #

Bug Fixes #

  • overlay: ensure smooth animation when opening modal overlays (#4879) (cd8dad7)
  • overlay: overlay closing another overlay (#4880) (30434fa)
  • overlay: remove flex display for dialog (#4902) (48448ea)

1.0.0 (2024-10-31) #

Note: Version bump only for package @spectrum-web-components/overlay

0.49.0 (2024-10-15) #

Note: Version bump only for package @spectrum-web-components/overlay

0.48.1 (2024-10-01) #

Note: Version bump only for package @spectrum-web-components/overlay

0.48.0 (2024-09-17) #

Note: Version bump only for package @spectrum-web-components/overlay

0.47.2 (2024-09-03) #

Note: Version bump only for package @spectrum-web-components/overlay

0.47.1 (2024-08-27) #

Note: Version bump only for package @spectrum-web-components/overlay

0.47.0 (2024-08-20) #

Features #

  • breadcrumbs: add Breadcrumbs component (#4578) (acd4b5e)

0.46.0 (2024-08-08) #

Note: Version bump only for package @spectrum-web-components/overlay

0.45.0 (2024-07-30) #

Bug Fixes #

  • overlay replace at() polyfill (#4628) (8cef2c6) Note: Version bump only for package @spectrum-web-components/overlay

0.44.0 (2024-07-15) #

0.43.0 (2024-06-11) #

0.42.5 (2024-05-24) #

Bug Fixes #

  • coachmark,overlay: adjust imports of overlay and coachmark (#4455) (39706da)
  • overlay: ensure hint Overlays within shadow roots open as expected (#4443) (7dd64b9)
  • overlay: ensure that passing "open" to the directive manages a single strategy (#4474) (15d6ac7)
  • overlay: persist "host" in directive rendered Overlay content (#4475) (5d189c2)

0.42.4 (2024-05-14) #

Bug Fixes #

  • action-menu: allow menu groups to handle their own selections (#4397) (5a19051)
  • base: move lit imports to base (#4416) (b7cb07e)
  • overlay: prevent "receivesFocus=false" overlays from returning focus (607819f)
  • slider,overlay: ensure that pointer events in Slider are handled as expected in Overlay (#4438) (db193e8)
  • styles,theme: add S2 tokens and theme (#4241) (a29e4a2), closes #4232 #4228
  • theme: deprecate theme property for system (#4230) (ac26168)

0.42.3 (2024-05-01) #

Bug Fixes #

  • overlay: prevent "receivesFocus=false" overlays from returning focus (607819f)
  • theme: deprecate theme property for system (#4230) (ac26168)

0.42.2 (2024-04-03) #

Note: Version bump only for package @spectrum-web-components/overlay

0.42.1 (2024-04-02) #

Note: Version bump only for package @spectrum-web-components/overlay

0.42.0 (2024-03-19) #

Bug Fixes #

  • overlay: prevent focus based hover interaction without :focus-visible (79337ff)
  • overlay: prioritize non-"hint" Overlays on the same trigger (b9833f3)
  • picker: add loading state to the picker (#3110) (d91e2c9)
  • styles, theme: surface exports that omit Spectrum Vars proactively (#4142) (5b524c1)

0.41.2 (2024-03-05) #

Bug Fixes #

  • overlay: ensure "manual" Overlays ignore "light dismiss" when [popover] is not supported (#4121) (eb5e1ad)
  • overlay: leverage "transition-behavior" to persist top-layer content while closing (#4050) (e3dea14)
  • slider: double click on slider handle to reset slider position (#3991) (64c594a)

0.41.1 (2024-02-22) #

Note: Version bump only for package @spectrum-web-components/overlay

0.41.0 (2024-02-13) #

Bug Fixes #

  • support generating random IDs outside of secure contexts (485a67c)

0.40.5 (2024-02-05) #

Note: Version bump only for package @spectrum-web-components/overlay

0.40.4 (2024-01-29) #

Bug Fixes #

  • overlay: clean position data on close (edac590)

0.40.3 (2024-01-11) #

Bug Fixes #

  • overlay: automatically reposition overlay when the contents resize (83be807)
  • overlay: move closed overlays to "display: none" (fc0278b)
  • overlay: normalize popover toggling between native and synthetic [popover] usage (26fa692)
  • overlay: support positioning overlays within parents leveraging container-type rules (21044b3)
  • overlay: surface "overlay" property to "sp-opened" and "sp-closed" events (957f8e9)

0.40.2 (2023-12-18) #

Note: Version bump only for package @spectrum-web-components/overlay

0.40.1 (2023-12-05) #

Bug Fixes #

  • overlay: ensure events are only bound once (abe57ce)

0.40.0 (2023-11-16) #

Bug Fixes #

  • overlay: ensure manual overlays persist through interactions outside of their subtree (#3788) (ef5617f)

0.39.4 (2023-11-02) #

Bug Fixes #

  • overlay: add delay resolution from overlaid content (#3748) (5c4f1f6)
  • overlay: calculate more transforms (6538a45)
  • overlay: place longpress helper content in a more accessible, less layout affecting location (dd12c23)

0.39.3 (2023-10-18) #

Note: Version bump only for package @spectrum-web-components/overlay

0.39.2 (2023-10-13) #

Bug Fixes #

  • overlay: allow overlay to persist on hover (#3706) (7707040)

0.39.1 (2023-10-06) #

Note: Version bump only for package @spectrum-web-components/overlay

0.39.0 (2023-09-25) #

Bug Fixes #

  • overlay: allow "receives-focus" to target the root of an overlay (#3658) (0db1025)
  • overlay: ensure position when closing overlays over the top-layer (55fab0d)
  • overlay: reduce circular dependencies (25eeb71)

0.38.0 (2023-09-05) #

Bug Fixes #

  • action-menu: added static attribute support (#3573) (25889a8)
  • overlay: position for transformed and contained parents (ca8fd8a)

0.37.0 (2023-08-18) #

Bug Fixes #

  • address margin effected positioning (38c8cf2)
  • ensure submenus stay open when root it clicked again (83ced1c)
  • handle longpress and over filter overlays (483e52d)

Features #

  • overlay: ship Overlay API v2 (67b5d1b)

Performance Improvements #

  • make lots of things lazy (b8fa3ad)
  • open/close timing update (d4ebcd3)

0.36.0 (2023-08-18) #

Note: Version bump only for package @spectrum-web-components/overlay

0.35.0 (2023-07-31) #

Note: Version bump only for package @spectrum-web-components/overlay

0.34.0 (2023-07-11) #

Note: Version bump only for package @spectrum-web-components/overlay

0.33.2 (2023-06-14) #

Note: Version bump only for package @spectrum-web-components/overlay

0.33.0 (2023-06-08) #

Note: Version bump only for package @spectrum-web-components/overlay

0.32.0 (2023-06-01) #

Bug Fixes #

  • overlay: ensure CSS calcs resolve to the expected measurement value (51a3feb)

Features #

  • popover: use core tokens (68328cc)

0.31.0 (2023-05-17) #

Bug Fixes #

  • overlay: address review comments (dd8b985)
  • overlay: removes use of px units in overlay stack (122f96c)
  • overlay: stop the tab trapping if shadow root is not found (4f0ec46)

0.30.0 (2023-05-03) #

Bug Fixes #

  • abstract "hasVisibleFocusInTree" functionality and return trigger focus after close (4f39f2c)
  • add content flow fallbacks to the position manager (c008957)
  • allow "updateComplete" to resolve to a boolean like the LitElement default (6127946)
  • allow contextmenu event passing to pierce shadow roots (05b69e9)
  • allow detached elements to be used as content for an overlay (3ad8383)
  • allow Picker to be reparented (39e7309)
  • centralize updated first focusable selector (300e84c)
  • close modal overlays with contextmenu events and pass those to the underlying page (9e83f3c)
  • constrain overlay to available window size (9729b55)
  • correct @element jsDoc listing across library (c97a632)
  • correct add/remove timing of overlay events (474ec6e)
  • correct overlay closure order or operations for manual override (0b7a8c4)
  • correct the relationship between overlayWillCloseCallback and phased animations (c63db8d)
  • delete the used cleanup method (942ef0f)
  • describe longpress button to screen readers (acdcaf4)
  • dialog: updates for delivering dialog content accessibly (f0ed33c)
  • dropdown: correct conditional check (a3a790f)
  • ensure browser understandable extensions (f4e59f7)
  • ensure focus is managed when tabbing out of a menu (9bfa81d)
  • ensure Overlay.update bypasses the auto close mechanism (8f2aa2e)
  • ensure that an overlay can be released even if it does not complete its fade in animation (4cbb36f)
  • ensure that entering an ancestor Menu Item without a submen closes related submenus (efe5fa1)
  • expand sync offering for elements with overlay content (0195843)
  • include default export in the "exports" fields (f32407d)
  • include sync builds in publication configuration (e731673)
  • include the "types" entry in package.json files (b432f59)
  • keep parent overlays open when not closing child hover overlays (643fcff)
  • leverage "dvh" rather than measured screen height (84b9df0)
  • manage "lang" via context provided by "sp-theme" (b1e3457)
  • menu: add support for submenu interactions (68399af)
  • overlay: add overlay lifecycle methods to stack management (9361527)
  • overlay: allow [type="modal"] hover overlays to be closed (5a6802b)
  • overlay: allow external style access to "sp-theme" elements in overlays as a CSS part (a107f66)
  • overlay: allow overlay-trigger to declaratively open overlay content (194a44e)
  • overlay: close when overlay-trigger becomes [disabled] (6f27e25)
  • overlay: correct overlay content sizing (d9bcd6f)
  • overlay: do not focus the trigger when closing an overlay, unless expected (21d7dfe)
  • overlay: enforce the full frame (63628e9)
  • overlay: ensure overlay addition occurs after closing previous (7d2b102)
  • overlay: ensure undefined data is not passed into theme (3e2e1ca)
  • overlay: export OverlayTriggerInteractions type (4caec7f)
  • overlay: extend state machine to manage disposal process (f0f26af)
  • overlay: focus closure action on ancestor scroll, not participant resize (925af0a)
  • overlay: handle hover/longpress more directly via the "open" attribute (7b2b64b)
  • overlay: init tab trapping on OverlayStack construction (a3121e3)
  • overlay: measure initial overlay data offscreen (fecda5a)
  • overlay: move "escape" listener to "keydown" (813b341)
  • overlay: new popper version tracks scroll through assigned slots (ea2bac4)
  • overlay: only "tab trap" when you mean to (74e1bd2)
  • overlay: override SpectrumCSS tip rules and process usage in popper (aad3dec)
  • overlay: persist hover overlay when there is not click content (27111a9)
  • overlay: place return focus element on demand (d262237)
  • overlay: reduce DOM and use of "display: contents" for simplicity and accessibility (2e02075)
  • overlay: reduce the control active-overlay places on its content (9d12571)
  • overlay: remove trapped content from a11y tree, manage focus, open projected content (6c496c0)
  • overlay: remove unused dependency (a3f3a72)
  • overlay: reset cached values and applied CSS before "updating" overlays (b871e52)
  • overlay: resolve async races with closeOverlays and manageOpen (ff3738e)
  • overlay: track "modalRoots" for expanded overlay management (dceccb1)
  • overlay: traverse up through shadow roots when determining parent overlay (27f232c)
  • overlay: use esm build from popper and point through to types (078ca0f)
  • overlay: use isolatedModules in tsconfig (48d6069)
  • overlay: use tabindex=-1 but always remove it on open (6047003)
  • overlay: vend a VirtualTrigger for overlays with no element trigger (a359c60)
  • picker: use "modal" as the menu overlay interaction (c8fbbe2)
  • prevent "hover" overlays from receiving focus (7bd5ac2)
  • prevent "hover" overlays from returning focus to the root of a parent modal (ceb8fa7)
  • prevent leaving multiple submenus open at a time (d2bfbb2)
  • prevent longpress when interacting with context menu (f8b0732)
  • prevent touch scolling on non-modal content (e471feb)
  • special case the possibility of leaving an overlay trigger by entering its overlay content (c32a075)
  • theme: track default theme values dynamically (a0c306c)
  • tooltip: correct arrow orientation, remove popper-arrow-rotate (fcd6ea2)
  • update "reparentChildren" types for flexibility (2d358be)
  • update presence confirmation so popper is available on update (24f8380)
  • update screen reader interface with menu items list (16756b5)
  • update when events are added to manage overlays (60cddac)
  • use "fixed" strategy to prevent unexpected overlay placement (e39e108)
  • use height: 100% to avoid layout breaks (1498129)
  • use latest @spectrum-css/* versions (c35eb86)
  • use less restrictive overlay sizing (f6917aa)
  • use typescript@^4.5 for "native" document.fonts typings (a3e4aea)
  • wait for fonts ready before positioning overlays (cb8026a)

Features #

  • add open/close events for some menus and overlays (17f0a58)
  • add support for Spectrum Express (12bfe99)
  • adopt DNA@7 base Spectrum CSS (e08cafd)
  • allow activation of longpress content (55e71fd)
  • delivery dev mode messages in various packages (62370a1)
  • dropdown: open menu UI with overlay system (9811eeb)
  • field-group: add field-group pattern (f8d265c)
  • include all Dev Mode files in side effects (f70817c)
  • join overlay-root and overlay-trigger as overlay (dcde42c)
  • leverage "exports" field in package.json (321abd7)
  • leverage latest Spectrum button API (9caf2f6)
  • overlay: manage focus throwing and tab trapping (27a0b53)
  • overlay: move entire package behind dynamic import by default (9b0a74d)
  • picker: process field-label content for more accurate a11y tree (dc9df54)
  • picker: support responsive delivery of menu (20031d1)
  • progress-bar: use core tokens (540552e)
  • reparentChildren - refactored arguments - breaking change (dea2bc5)
  • rework overlays to use popper (e17d1bb)
  • shared pkg versions, devmode define warning, registry-conflicts docs (6e49565)
  • sidenav: add keyboard accessibility (6ff622b)
  • split-button: add split-button pattern (4833a59)
  • story-decorator: add story decorator to replace knobs for theme application (7c0c6be)
  • update lit-* dependencies, wip (377f3c8)
  • use latest exports specification (a7ecf4b)

Performance Improvements #

  • use "sideEffects" listing in package.json (7271614)

Reverts #

  • Revert "chore: release new versions" (a6d655d)

0.19.5 (2023-04-24) #

Note: Version bump only for package @spectrum-web-components/overlay

0.19.4 (2023-04-05) #

Note: Version bump only for package @spectrum-web-components/overlay

0.19.3 (2023-03-22) #

Note: Version bump only for package @spectrum-web-components/overlay

0.19.2 (2023-03-08) #

Note: Version bump only for package @spectrum-web-components/overlay

0.19.1 (2023-02-13) #

Note: Version bump only for package @spectrum-web-components/overlay

0.19.0 (2023-02-08) #

Features #

  • progress-bar: use core tokens (540552e)

0.18.11 (2023-01-23) #

Bug Fixes #

  • overlay: reset cached values and applied CSS before "updating" overlays (b871e52)

0.18.10 (2023-01-09) #

Bug Fixes #

  • use "fixed" strategy to prevent unexpected overlay placement (e39e108)

0.18.9 (2022-12-08) #

Bug Fixes #

  • ensure Overlay.update bypasses the auto close mechanism (8f2aa2e)
  • leverage "dvh" rather than measured screen height (84b9df0)

0.18.8 (2022-11-21) #

Bug Fixes #

  • ensure that an overlay can be released even if it does not complete its fade in animation (4cbb36f)
  • overlay: focus closure action on ancestor scroll, not participant resize (925af0a)

0.18.7 (2022-11-14) #

Bug Fixes #

  • keep parent overlays open when not closing child hover overlays (643fcff)

0.18.6 (2022-10-28) #

Note: Version bump only for package @spectrum-web-components/overlay

0.18.5 (2022-10-17) #

Bug Fixes #

  • correct the relationship between overlayWillCloseCallback and phased animations (c63db8d)
  • overlay: init tab trapping on OverlayStack construction (a3121e3)

0.18.4 (2022-10-10) #

Note: Version bump only for package @spectrum-web-components/overlay

0.18.3 (2022-09-15) #

Bug Fixes #

  • special case the possibility of leaving an overlay trigger by entering its overlay content (c32a075)

0.18.2 (2022-09-14) #

Bug Fixes #

  • overlay: move "escape" listener to "keydown" (813b341)

0.18.1 (2022-08-24) #

Bug Fixes #

  • prevent "hover" overlays from returning focus to the root of a parent modal (ceb8fa7)
  • prevent longpress when interacting with context menu (f8b0732)

0.18.0 (2022-08-09) #

Features #

  • include all Dev Mode files in side effects (f70817c)

0.17.0 (2022-08-04) #

Bug Fixes #

  • overlay: export OverlayTriggerInteractions type (4caec7f)

Features #

  • delivery dev mode messages in various packages (62370a1)

0.16.5 (2022-07-18) #

Note: Version bump only for package @spectrum-web-components/overlay

0.16.4 (2022-06-29) #

Bug Fixes #

  • ensure that entering an ancestor Menu Item without a submen closes related submenus (efe5fa1)

0.16.3 (2022-06-07) #

Bug Fixes #

  • prevent leaving multiple submenus open at a time (d2bfbb2)

0.16.2 (2022-05-27) #

Bug Fixes #

  • add content flow fallbacks to the position manager (c008957)
  • prevent "hover" overlays from receiving focus (7bd5ac2)

0.16.1 (2022-05-12) #

Note: Version bump only for package @spectrum-web-components/overlay

0.16.0 (2022-04-21) #

Bug Fixes #

  • allow Picker to be reparented (39e7309)
  • use less restrictive overlay sizing (f6917aa)

Features #

  • add support for Spectrum Express (12bfe99)
  • reparentChildren - refactored arguments - breaking change (dea2bc5)

0.15.3 (2022-03-30) #

Note: Version bump only for package @spectrum-web-components/overlay

0.15.2 (2022-03-08) #

Note: Version bump only for package @spectrum-web-components/overlay

0.15.1 (2022-03-08) #

Note: Version bump only for package @spectrum-web-components/overlay

0.15.0 (2022-03-04) #

Bug Fixes #

  • menu: add support for submenu interactions (68399af)

Features #

  • leverage latest Spectrum button API (9caf2f6)

0.14.1 (2022-02-22) #

Bug Fixes #

  • dialog: updates for delivering dialog content accessibly (f0ed33c)
  • overlay: measure initial overlay data offscreen (fecda5a)

0.14.0 (2022-02-02) #

Features #

  • picker: support responsive delivery of menu (20031d1)

0.13.4 (2022-01-26) #

Bug Fixes #

  • overlay: remove unused dependency (a3f3a72)

0.13.3 (2022-01-26) #

Bug Fixes #

  • describe longpress button to screen readers (acdcaf4)

0.13.2 (2022-01-07) #

Bug Fixes #

  • overlay: reduce DOM and use of "display: contents" for simplicity and accessibility (2e02075)

0.13.1 (2021-12-13) #

Bug Fixes #

  • use typescript@^4.5 for "native" document.fonts typings (a3e4aea)

0.13.0 (2021-11-08) #

Features #

  • update lit-* dependencies, wip (377f3c8)

0.12.1 (2021-11-08) #

Bug Fixes #

  • abstract "hasVisibleFocusInTree" functionality and return trigger focus after close (4f39f2c)
  • prevent touch scolling on non-modal content (e471feb)

0.12.0 (2021-11-02) #

Bug Fixes #

  • centralize updated first focusable selector (300e84c)
  • update screen reader interface with menu items list (16756b5)
  • picker: use "modal" as the menu overlay interaction (c8fbbe2)

Features #

  • adopt DNA@7 base Spectrum CSS (e08cafd)

0.11.16 (2021-10-12) #

Bug Fixes #

  • overlay: allow [type="modal"] hover overlays to be closed (5a6802b)
  • overlay: resolve async races with closeOverlays and manageOpen (ff3738e)
  • overlay: traverse up through shadow roots when determining parent overlay (27f232c)

0.11.15 (2021-09-20) #

Bug Fixes #

  • allow contextmenu event passing to pierce shadow roots (05b69e9)
  • correct add/remove timing of overlay events (474ec6e)

0.11.14 (2021-09-13) #

Bug Fixes #

  • close modal overlays with contextmenu events and pass those to the underlying page (9e83f3c)

0.11.13 (2021-08-24) #

Bug Fixes #

  • correct @element jsDoc listing across library (c97a632)

0.11.12 (2021-08-17) #

Bug Fixes #

  • update when events are added to manage overlays (60cddac)

0.11.11 (2021-08-03) #

Bug Fixes #

  • allow "updateComplete" to resolve to a boolean like the LitElement default (6127946)
  • expand sync offering for elements with overlay content (0195843)

0.11.10 (2021-07-22) #

Bug Fixes #

  • overlay: allow external style access to "sp-theme" elements in overlays as a CSS part (a107f66)
  • delete the used cleanup method (942ef0f)

0.11.9 (2021-07-01) #

Bug Fixes #

  • allow detached elements to be used as content for an overlay (3ad8383)
  • manage "lang" via context provided by "sp-theme" (b1e3457)

0.11.8 (2021-06-16) #

Note: Version bump only for package @spectrum-web-components/overlay

0.11.7 (2021-06-07) #

Bug Fixes #

  • ensure focus is managed when tabbing out of a menu (9bfa81d)
  • overlay: vend a VirtualTrigger for overlays with no element trigger (a359c60)

0.11.6 (2021-05-24) #

Bug Fixes #

  • overlay: add overlay lifecycle methods to stack management (9361527)
  • overlay: use tabindex=-1 but always remove it on open (6047003)

0.11.5 (2021-05-12) #

Bug Fixes #

  • overlay: reduce the control active-overlay places on its content (9d12571)
  • update "reparentChildren" types for flexibility (2d358be)
  • update presence confirmation so popper is available on update (24f8380)

0.11.4 (2021-04-15) #

Note: Version bump only for package @spectrum-web-components/overlay

0.11.3 (2021-04-09) #

Note: Version bump only for package @spectrum-web-components/overlay

0.11.2 (2021-03-29) #

Note: Version bump only for package @spectrum-web-components/overlay

0.11.1 (2021-03-22) #

Bug Fixes #

  • overlay: handle hover/longpress more directly via the "open" attribute (7b2b64b)

0.11.0 (2021-03-22) #

Bug Fixes #

  • overlay: allow overlay-trigger to declaratively open overlay content (194a44e)
  • overlay: persist hover overlay when there is not click content (27111a9)

Features #

  • picker: process field-label content for more accurate a11y tree (dc9df54)

0.10.1 (2021-03-05) #

Note: Version bump only for package @spectrum-web-components/overlay

0.10.0 (2021-03-04) #

Bug Fixes #

  • overlay: correct overlay content sizing (d9bcd6f)
  • overlay: track "modalRoots" for expanded overlay management (dceccb1)
  • wait for fonts ready before positioning overlays (cb8026a)

Features #

  • use latest exports specification (a7ecf4b)

0.9.0 (2021-02-11) #

Bug Fixes #

  • overlay: place return focus element on demand (d262237)

Features #

  • allow activation of longpress content (55e71fd)

0.8.2 (2021-02-02) #

Note: Version bump only for package @spectrum-web-components/overlay

0.8.1 (2021-01-28) #

Bug Fixes #

  • overlay: remove trapped content from a11y tree, manage focus, open projected content (6c496c0)
  • tooltip: correct arrow orientation, remove popper-arrow-rotate (fcd6ea2)

0.8.0 (2021-01-21) #

Bug Fixes #

  • overlay: do not focus the trigger when closing an overlay, unless expected (21d7dfe)
  • include the "types" entry in package.json files (b432f59)
  • overlay: use esm build from popper and point through to types (078ca0f)
  • overlay: use isolatedModules in tsconfig (48d6069)
  • use latest @spectrum-css/* versions (c35eb86)

Features #

  • add open/close events for some menus and overlays (17f0a58)
  • field-group: add field-group pattern (f8d265c)
  • story-decorator: add story decorator to replace knobs for theme application (7c0c6be)

0.7.0 (2021-01-13) #

Bug Fixes #

  • overlay: do not focus the trigger when closing an overlay, unless expected (21d7dfe)
  • include the "types" entry in package.json files (b432f59)
  • overlay: use esm build from popper and point through to types (078ca0f)
  • overlay: use isolatedModules in tsconfig (48d6069)
  • use latest @spectrum-css/* versions (c35eb86)

Features #

  • add open/close events for some menus and overlays (17f0a58)
  • field-group: add field-group pattern (f8d265c)
  • story-decorator: add story decorator to replace knobs for theme application (7c0c6be)

0.6.4 (2020-10-12) #

Note: Version bump only for package @spectrum-web-components/overlay

0.6.3 (2020-10-12) #

Bug Fixes #

  • overlay: close when overlay-trigger becomes disabled
  • include default export in the "exports" fields (f32407d)

0.6.2 (2020-09-25) #

Note: Version bump only for package @spectrum-web-components/overlay

0.6.1 (2020-09-15) #

Bug Fixes #

  • overlay: only "tab trap" when you mean to (74e1bd2)

0.6.0 (2020-08-31) #

Bug Fixes #

  • correct overlay closure order or operations for manual override (0b7a8c4)

Features #

  • split-button: add split-button pattern (4833a59)

0.5.2 (2020-08-19) #

Note: Version bump only for package @spectrum-web-components/overlay

0.5.1 (2020-08-13) #

Bug Fixes #

  • include sync builds in publication configuration (e731673)

0.5.0 (2020-08-13) #

Bug Fixes #

  • overlay: enforce the full frame (63628e9)
  • overlay: ensure overlay addition occurs after closing previous (7d2b102)

Features #

  • overlay: move entire package behind dynamic import by default (9b0a74d)

0.4.3 (2020-08-05) #

Bug Fixes #

  • use height: 100% to avoid layout breaks (1498129)

0.4.2 (2020-07-24) #

Bug Fixes #

  • ensure browser understandable extensions (f4e59f7)

0.4.1 (2020-07-22) #

Note: Version bump only for package @spectrum-web-components/overlay

0.4.0 (2020-07-17) #

Features #

  • overlay: manage focus throwing and tab trapping (27a0b53)
  • leverage "exports" field in package.json (321abd7)

0.3.8 (2020-06-08) #

Bug Fixes #

  • overlay: ensure undefined data is not passed into theme (3e2e1ca)

0.3.7 (2020-05-08) #

Bug Fixes #

  • dropdown: correct conditional check (a3a790f)

0.3.6 (2020-05-08) #

Bug Fixes #

  • constrain overlay to available window size (9729b55)

0.3.5 (2020-04-16) #

Performance Improvements #

  • use "sideEffects" listing in package.json (7271614)

0.3.4 (2020-04-10) #

Bug Fixes #

  • overlay: new popper version tracks scroll through assigned slots (ea2bac4)

0.3.3 (2020-04-07) #

Note: Version bump only for package @spectrum-web-components/overlay

0.3.2 (2020-03-16) #

Bug Fixes #

  • theme: track default theme values dynamically (a0c306c)

0.3.1 (2020-03-11) #

Bug Fixes #

  • overlay: extend state machine to manage disposal process (f0f26af)

0.3.0 (2020-02-24) #

Features #

  • dropdown: open menu UI with overlay system (9811eeb)

0.2.1 (2020-02-05) #

Bug Fixes #

  • overlay: override SpectrumCSS tip rules and process usage in popper (aad3dec)

0.2.0 (2020-01-30) #

Features #

  • rework overlays to use popper (e17d1bb)

0.1.0 (2020-01-06) #

Features #

  • join overlay-root and overlay-trigger as overlay (dcde42c)
  • sidenav: add keyboard accessibility (6ff622b)

Description #

An <sp-overlay> element is used to decorate content that you would like to present to your visitors as "overlaid" on the rest of the application. This includes dialogs (modal and not), pickers, tooltips, context menus, et al.

Usage #

See it on NPM! How big is this package in your project?

yarn add @spectrum-web-components/overlay

Import the side effectful registration of <sp-overlay> as follows:

import '@spectrum-web-components/overlay/sp-overlay.js';

When looking to leverage the Overlay base class as a type and/or for extension purposes, do so via:

import {
    Overlay
} from '@spectrum-web-components/overlay';

Example #

By leveraging the trigger attribute to pass an ID reference to another element with in the same DOM tree, your overlay will be positioned in relation to this element. When the ID reference is followed by an @ symbol and interaction type, like click, hover, or longpress, the overlay will bind itself to the referenced element via the DOM events associated with that interaction. For example, the <sp-button> below has an id of trigger, and the <sp-overlay> is provided the trigger attribute with the value trigger@click. This creates an association between the overlay and the <sp-button> that opens the overlay when the button is clicked.

<sp-button id="trigger">Overlay Trigger</sp-button>

<!-- Opening an overlay via a click interaction -->
<sp-overlay trigger="trigger@click" placement="bottom">
    <sp-popover>
        <sp-dialog>
            <h2 slot="heading">Clicking opens this popover...</h2>
            <p>But, it really could be anything. Really.</p>
        </sp-dialog>
    </sp-popover>
</sp-overlay>

<!-- Opening an overlay via a hover interaction -->
<sp-overlay trigger="trigger@hover" placement="bottom">
    <sp-tooltip>
        I'm a tooltip and I'm triggered by hovering over the button!
    </sp-tooltip>
</sp-overlay>

When a <sp-overlay> element is opened, it will pass that state to its direct children elements as the property open, which it will set to true. Elements should react to this by initiating any transition between closed and open that they see fit. Similarly, open will be set to false when the <sp-overlay> element is closed.

Action Bar #

<style>
    .overlay-demo-popover sp-action-group {
        padding: var(--spectrum-actiongroup-vertical-spacing-regular);
    }
    #overlay-demo {
        position: static;
    }
    #overlay-demo:not(:defined),
    #overlay-demo *:not(:defined) {
        display: none;
    }
</style>
<sp-popover id="overlay-demo" class="overlay-demo-popover" open>
    <sp-action-group vertical quiet emphasized selects="single">
        <sp-action-button id="trigger-1" hold-affordance>
            <sp-icon-anchor-select slot="icon"></sp-icon-anchor-select>
        </sp-action-button>
        <sp-action-button id="trigger-2" hold-affordance>
            <sp-icon-polygon-select slot="icon"></sp-icon-polygon-select>
        </sp-action-button>
        <sp-action-button id="trigger-3" hold-affordance>
            <sp-icon-rect-select slot="icon"></sp-icon-rect-select>
        </sp-action-button>
    </sp-action-group>
    <sp-overlay trigger="trigger-1@hover" type="hint">
        <sp-tooltip>Hover</sp-tooltip>
    </sp-overlay>
    <sp-overlay
        trigger="trigger-1@longpress"
        type="auto"
        placement="right-start"
    >
        <sp-popover class="overlay-demo-popover" tip>
            <sp-action-group vertical quiet>
                <sp-action-button>
                    <sp-icon-anchor-select slot="icon"></sp-icon-anchor-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-polygon-select
                        slot="icon"
                    ></sp-icon-polygon-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-rect-select slot="icon"></sp-icon-rect-select>
                </sp-action-button>
            </sp-action-group>
        </sp-popover>
    </sp-overlay>
    <sp-overlay trigger="trigger-2@hover" type="hint">
        <sp-tooltip>Hover</sp-tooltip>
    </sp-overlay>
    <sp-overlay
        trigger="trigger-2@longpress"
        type="auto"
        placement="right-start"
    >
        <sp-popover class="overlay-demo-popover" tip>
            <sp-action-group vertical quiet>
                <sp-action-button>
                    <sp-icon-anchor-select slot="icon"></sp-icon-anchor-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-polygon-select
                        slot="icon"
                    ></sp-icon-polygon-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-rect-select slot="icon"></sp-icon-rect-select>
                </sp-action-button>
            </sp-action-group>
        </sp-popover>
    </sp-overlay>
    <sp-overlay trigger="trigger-3@hover" type="hint">
        <sp-tooltip>Hover</sp-tooltip>
    </sp-overlay>
    <sp-overlay
        trigger="trigger-3@longpress"
        type="auto"
        placement="right-start"
    >
        <sp-popover class="overlay-demo-popover" tip>
            <sp-action-group vertical quiet>
                <sp-action-button>
                    <sp-icon-anchor-select slot="icon"></sp-icon-anchor-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-polygon-select
                        slot="icon"
                    ></sp-icon-polygon-select>
                </sp-action-button>
                <sp-action-button>
                    <sp-icon-rect-select slot="icon"></sp-icon-rect-select>
                </sp-action-button>
            </sp-action-group>
        </sp-popover>
    </sp-overlay>
</sp-popover>

API #

<sp-overlay
    ?open=${boolean}
    ?delayed=${boolean}
    offset=${Number | [Number, Number]}
    placement=${Placement}
    receives-focus=${'true' | 'false' | 'auto' (default)
    trigger=${string | ${string}@${string}}
    .triggerElement=${HTMLElement}
    .triggerInteraction=${'click' | 'longpress' | 'hover'}
    type=${'auto' | 'hint' | 'manual' | 'modal' | 'page'}
></sp-overlay>

API value interactions #

When a triggerElement is present, either through an ID reference established via the trigger attribute or by directly setting the triggerElement property, a chain on configuration begins:

  • if a triggerInteraction is available, either through the id@interaction IDL on the trigger attribute or directly setting the triggerInteraction property, the <sp-overlay> will be bound to the resolved triggerElement via the triggerInteraction provided
  • if a placement is available when the <sp-overlay> is open and displaying its contents, those contents will be positioned relative to the triggerElement as per that placement
    • if an offset is also available the <sp-overlay> will distance itself from the triggerElement in accordance with the value of the offset
    • if you have a placement but not a triggerElement the <sp-overlay> will not be positioned due to their being nothing for the placement to reference when so doing
  • if no placement is available the content will not be placed with the expectation that the content itself or the consuming application will handle placement of the overlaid content. This is commonly what will happen for type="modal" and type="page" overlays as they are likely meant to cover the entire screen, whether visibly (via an <sp-underlay>, an element that includes one, or similar) or figuratively (as when modal content is not delivered with a backdrop or scrim).

Overlay types #

The type of an Overlay outlines a number of things about the interaction model within which is works.

'modal' Overlays are opened with the showModal() method on a <dialog> element, which causes the Overlay to accept focus and trap the tab stop within the content of said Overlay.

They should be used when you need to ensure that the user has interacted with the content of the Overlay before continuing with their work. This is commonly used for dialogs that require a user to confirm or cancel an action before continuing.

<sp-button id="trigger">open modal</sp-button>
<sp-overlay trigger="trigger@click" type="modal">
    <sp-dialog-wrapper headline="Signin form" dismissable underlay>
        <p>I am a modal type overlay.</p>
        <sp-field-label>Enter your email</sp-field-label>
        <sp-textfield placeholder="test@gmail.com"></sp-textfield>
        <sp-action-button
            onClick="
                this.dispatchEvent(
                    new Event('close', {
                        bubbles: true,
                        composed: true,
                    })
                );
            "
        >
            Sign in
        </sp-action-button>
    </sp-dialog-wrapper>
</sp-overlay>

Page #

'page' Overlays will act in a similar manner to a 'modal' Overlay, however they will not be allowed to close via the "light dismiss" algorithm (e.g. the Escape key).

A page overlay could be used for a full-screen menu on a mobile website. When the user clicks on the menu button, the entire screen is covered with the menu options.

<sp-button id="trigger">open page</sp-button>
<sp-overlay trigger="trigger@click" type="page">
    <sp-dialog-wrapper
        headline="Full screen menu"
        mode="fullscreenTakeover"
        cancel-label="Close"
    >
        <p>I am a page type overlay.</p>
    </sp-dialog-wrapper>
</sp-overlay>

Hint #

'hint' Overlays are much like tooltips so they are not just ephemeral, but they are delivered primarily as a visual helper and exist outside of the tab order. In this way, be sure not to place interactive content within this type of Overlay.

This overlay type does not accept focus and does not interfere with the user's interaction with the rest of the page.

<sp-button id="trigger">open hint</sp-button>
<sp-overlay trigger="trigger@hover" type="hint">
    <sp-tooltip>
        I am a hint type overlay. I am not interactive and will close when the
        user interacts with the page.
    </sp-tooltip>
</sp-overlay>

Auto #

'auto' Overlays provide a place for content that is ephemeral and interactive. These Overlays can accept focus but will close when losing that focus, or when interacting with other parts of the page.

<style>
    sp-toast {
        position: fixed;
        top: 1em;
        right: 1em;
    }
</style>
<sp-button id="trigger">open auto</sp-button>
<sp-overlay trigger="trigger@click" type="auto">
    <sp-toast variant="info">
        This is information that you should read.
    </sp-toast>
</sp-overlay>

Manual #

'manual' Overlays act much like 'auto' Overlays, but do not close when losing focus or interacting with other parts of the page.

Note: When a 'manual' Overlay is at the top of the "overlay stack", it will still respond to the Escape key and close.

<style>
    .chat-container {
        position: fixed;
        bottom: 1em;
        left: 1em;
    }
</style>
<sp-button id="trigger">open manual</sp-button>
<sp-overlay trigger="trigger@click" type="manual">
    <sp-popover class="chat-container">
        <sp-dialog dismissable>
            <span slot="heading">Chat Window</span>
            <sp-textfield placeholder="Enter your message"></sp-textfield>
            <sp-action-button>Send</sp-action-button>
        </sp-dialog>
    </sp-popover>
</sp-overlay>

Events #

When fully open the <sp-overlay> element will dispatch the sp-opened event, and when fully closed the sp-closed event will be dispatched. Both of these events are of type:

type OverlayStateEvent = Event & {
    overlay: Overlay;
};

The overlay value in this case will hold a reference to the actual <sp-overlay> that is opening or closing to trigger this event. Remember that some <sp-overlay> element (like those creates via the imperative API) can be transiently available in the DOM, so if you choose to build a cache of Overlay elements to some end, be sure to leverage a weak reference so that the <sp-overlay> can be garbage collected as desired by the browser.

When it is "fully" open or closed? #

"Fully" in this context means that all CSS transitions that have dispatched transitionrun events on the direct children of the <sp-overlay> element have successfully dispatched their transitionend or transitioncancel event. Keep in mind the following:

  • transition* events bubble; this means that while transition events on light DOM content of those direct children will be heard, those events will not be taken into account
  • transition* events are not composed; this means that transition events on shadow DOM content of the direct children will not propagate to a level in the DOM where they can be heard

This means that in both cases, if the transition is meant to be a part of the opening or closing of the overlay in question you will need to redispatch the transitionrun, transitionend, and transitioncancel events from that transition from the closest direct child of the <sp-overlay>.

Styling #

<sp-overlay> element will use the <dialog> element or popover attribute to project your content onto the top-layer of the browser, without being moved in the DOM tree. That means that you can style your overlay content with whatever techniques you are already leveraging to style the content that doesn't get overlaid. This means standard CSS selectors, CSS Custom Properties, and CSS Parts applied in your parent context will always apply to your overlaid content.

Top Layer over Complex CSS #

There are some complex CSS values that have not yet been covered by the positioning API that the <sp-overlay> element leverages to associate overlaid content with their trigger elements. In specific, properties like filter, when applied to a trigger element within which lives the related content to be overlaid, are not currently supported by the relationship created herein. If support for this is something that you and the work you are addressing would require, we'd love to hear from you in an issue. We'd be particularly interested in speaking with you if you were interested in contributing support/testing to ensure this capability for all consumers of the library.

Fallback support #

While the <dialog> element is widely supported by browsers, the popover attribute is still quite new. When leveraged in browsers that do not yet support the popover attribute, there may be additional intervention required to ensure your content is delivered to your visitors as expected.

Complex layered #

When an overlay is placed within a page with complex layering, the content therein can fall behind other content in the z-index stack. The following example is somewhat contrived but, imagine a toolbar next to a properties panel. If the toolbar has a lower z-index than the properties panel, any overlaid content (tooltips, etc.) within that toolbar will display underneath any content in the properties panel with which it may share pixels.

<div class="complex-layered-demo">
    <div class="complex-layered-holder">
        <sp-action-button id="complex-layered">Trigger</sp-action-button>
        <sp-overlay
            trigger="complex-layered@hover"
            type="hint"
            placement="bottom-start"
        >
            <sp-tooltip>
                I can be partially blocked when [popover] is not available
            </sp-tooltip>
        </sp-overlay>
    </div>
    <div class="complex-layered-blocker"></div>
</div>
<style>
    .complex-layered-demo {
        position: relative;
    }
    .complex-layered-holder {
        z-index: 1;
        position: relative;
    }
    .complex-layered-blocker {
        position: relative;
        z-index: 10;
        background: white;
        width: 100%;
        height: 40px;
    }
</style>

Properly managed z-index values will support working around this issue while browsers work to adopt the popover attribute. In this demo, you can achieve the same output by sharing one z-index between the various pieces of content, removing z-index values altogether, or raising the .complex-layered-holder element to a higher z-index than the .complex-layered-blocker element.

Contained #

CSS Containment gives a developer direct control over how the internals of one element affect the paint and layout of the internals of other elements on the same page. While leveraging some of its values can offer performance gains, they can interrupt the delivery of your overlaid content.

<div class="contained-demo">
    <sp-action-button id="contained">Trigger</sp-action-button>
    <sp-overlay trigger="contained@hover" type="hint" placement="bottom-start">
        <sp-tooltip>
            I can be blocked when [popover] is not available
        </sp-tooltip>
    </sp-overlay>
</div>
<style>
    .contained-demo {
        contain: content;
    }
</style>

You could just remove the contain rule. But, if you are not OK with simply removing the contain value, you still have options. If you would like to continue to leverage contain, you can place your "contained" content separately from your overlaid content, like so:

<div class="contained-demo">
    <sp-action-button id="contained-working">Trigger</sp-action-button>
</div>
<sp-overlay
    trigger="contained-working@hover"
    type="hint"
    placement="bottom-start"
>
    <sp-tooltip>I can be blocked when [popover] is not available</sp-tooltip>
</sp-overlay>
<style>
    .contained-demo {
        contain: content;
    }
</style>

<sp-overlay> accepts an ID reference via the trigger attribute to relate it to interactions and positioning in the DOM. To fulfill this reference the two elements need to be in the same DOM tree. However, <sp-overlay> alternatively accepts a triggerElement property that opens even more flexibility in addressing this situation.

Clip pathed #

clip-path can also restrict how content in an element is surfaced at paint time. When overlaid content should display outside of the clip-path, without the popover attribute, that content could be clipped.

<div class="clip-pathed-demo">
    <sp-action-button id="clip-pathed">Trigger</sp-action-button>
    <sp-overlay
        trigger="clip-pathed@hover"
        type="hint"
        placement="bottom-start"
    >
        <sp-tooltip>
            I can be blocked when [popover] is not available
        </sp-tooltip>
    </sp-overlay>
</div>
<style>
    .clip-pathed-demo {
        clip-path: inset(0 0);
    }
</style>

Here, again, working with your content needs (whether or not you want to leverage clip-path) or DOM structure (not colocating clipped and non-clipped content) will allow you to avoid this issue:

<div class="clip-pathed-demo">
    <sp-action-button id="clip-pathed-working">Trigger</sp-action-button>
</div>
<sp-overlay
    trigger="clip-pathed-working@hover"
    type="hint"
    placement="bottom-start"
>
    <sp-tooltip>I can be blocked when [popover] is not available</sp-tooltip>
</sp-overlay>
<style>
    .clip-pathed-demo {
        clip-path: inset(0 0);
    }
</style>

Non-overflowing, relative containers with z-index in Safari #

Under very specific conditions, WebKit will incorrectly clip fixed-position content. WebKit clips position: fixed elements within containers that have all of:

  1. position: relative
  2. overflow: clip or overflow: hidden
  3. z-index greater than zero

If you notice overlay clipping only in Safari, this is likely the culprit. The solution is to break up the conditions into separate elements to avoid triggering WebKit's bug. For example, leaving relative positioning and z-index on the outermost container while creating an inner container that enforces the overflow rules.