Overlays: API Table
class: OverlayController
Fields
| Name | Privacy | Type | Default | Description | Inherited From |
|---|---|---|---|---|---|
backdropNode | public | HTMLElement | The element that is placed behind the contentNode. When not provided and `hasBackdrop` is true, a backdropNode will be automatically created | ||
config | public | OverlayConfig | {} | ||
content | public | HTMLDialogElement | HTMLDivElement | The contentWrapperNode | ||
contentNode | public | HTMLElement | The most important element: the overlay itself | ||
contentWrapperNode | public | HTMLElement | The wrapper element of contentNode, used to supply inline positioning styles. When a Popper arrow is needed, it acts as parent of the arrow node. Will be automatically created for global and non projected contentNodes. Required when used in shadow dom mode or when Popper arrow is supplied. Essential for allowing webcomponents to style their projected contentNodes | ||
elementToFocusAfterHide | public | HTMLElement | The element that should be called `.focus()` on after dialog closes | ||
elevation | public | number | |||
handlesAccessibility | public | boolean | For non `isTooltip`: - sets aria-expanded=“true/false” and aria-haspopup=“true” on invokerNode - sets aria-controls on invokerNode - returns focus to invokerNode on hide - sets focus to overlay content(?) For `isTooltip`: - sets role=“tooltip” and aria-labelledby/aria-describedby on the content | ||
hasActiveBackdrop | public | ||||
hasBackdrop | public | boolean | Whether it should have a backdrop (currently exclusive to globalOverlayController) | ||
hidesOnEsc | public | boolean | Hides the overlay when pressing [ esc ] | ||
hidesOnOutsideClick | public | boolean | Hides the overlay when clicking next to it, exluding invoker | ||
hidesOnOutsideEsc | public | boolean | Hides the overlay when pressing esc, even when contentNode has no focus | ||
inheritsReferenceWidth | public | 'max' | 'full' | 'min' | 'none' | undefined | Will align contentNode with referenceNode (invokerNode by default) for local overlays. Usually needed for dropdowns. ‘max’ will prevent contentNode from exceeding width of referenceNode, ‘min’ guarantees that contentNode will be at least as wide as referenceNode. ‘full’ will make sure that the invoker width always is the same. | ||
invoker | public | HTMLElement | undefined | The invokerNode | ||
invokerNode | public | HTMLElement | undefined | The interactive element (usually a button) invoking the dialog or tooltip | ||
invokerRelation | public | 'label' | 'description'| undefined | By default, the tooltip content is a ‘description’ for the invoker (uses aria-describedby). Setting this property to ‘label’ makes the content function as a label (via aria-labelledby) | ||
isAlertDialog | public | The alertdialog role is to be used on modal alert dialogs that interrupt a user’s workflow to communicate an important message and require a response. | |||
isBlocking | public | boolean | Hides other overlays when mutiple are opened (currently exclusive to globalOverlayController) | ||
isShown | public | ||||
isTooltip | public | boolean | Has a totally different interaction- and accessibility pattern from all other overlays. Will behave as role=“tooltip” element instead of a role=“dialog” element | ||
manager | public | manager | |||
placementMode | public | 'global' | 'local' | undefined | Determines the connection point in DOM (body vs next to invoker). | ||
popperConfig | public | PopperOptions | Popper configuration. Will be used when placementMode is ‘local’ | ||
preventsScroll | public | boolean | Hides other overlays when mutiple are opened (currently exclusive to globalOverlayController) | ||
referenceNode | public | HTMLElement | The element that is used to position the overlay content relative to. Usually, this is the same element as invokerNode. Should only be provided when invokerNode should not be positioned against. | ||
trapsKeyboardFocus | public | boolean | Rotates tab, implicitly set when ‘isModal’ | ||
viewportConfig | public | ViewportConfig | Viewport configuration. Will be used when placementMode is ‘global’ | ||
visibilityTriggerFunction | public | ||||
_contentId | protected | `overlay-content--${Math.random().toString(36).slice(2, 10)}` | |||
_defaultConfig | protected | OverlayConfig | { placementMode: undefined, contentNode: config.contentNode, contentWrapperNode: config.contentWrapperNode, invokerNode: config.invokerNode, backdropNode: config.backdropNode, referenceNode: undefined, elementToFocusAfterHide: config.invokerNode, inheritsReferenceWidth: 'none', hasBackdrop: false, isBlocking: false, preventsScroll: false, trapsKeyboardFocus: false, hidesOnEsc: false, hidesOnOutsideEsc: false, hidesOnOutsideClick: false, isTooltip: false, isAlertDialog: false, invokerRelation: 'description', visibilityTriggerFunction: undefined, handlesAccessibility: false, popperConfig: { placement: 'top', strategy: 'fixed', modifiers: [ { name: 'preventOverflow', enabled: true, options: { boundariesElement: 'viewport', padding: 8, // viewport-margin for shifting/sliding }, }, { name: 'flip', options: { boundariesElement: 'viewport', padding: 16, // viewport-margin for flipping }, }, { name: 'offset', enabled: true, options: { offset: [0, 8], // horizontal and vertical margin (distance between popper and referenceElement) }, }, { name: 'arrow', enabled: false, }, ], }, viewportConfig: { placement: 'center', }, zIndex: 9999, } | ||
_referenceNode | protected | HTMLElement | undefined |
Methods
| Name | Privacy | Description | Parameters | Return | Inherited From |
|---|---|---|---|---|---|
addEventListener | public | type, callback, options | EventTarget | ||
dispatchEvent | public | event | EventTarget | ||
hide | public | ||||
removeEventListener | public | type, callback, options | EventTarget | ||
show | public | elementToFocusAfterHide: HTMLElement | |||
teardown | public | ||||
toggle | public | ||||
transitionHide | public | Method to be overriden by subclassers | hideConfig: {backdropNode:HTMLElement, contentNode:HTMLElement} | ||
transitionShow | public | To be overridden by subclassers | showConfig: {backdropNode:HTMLElement; contentNode:HTMLElement} | ||
updateConfig | public | Allows to dynamically change the overlay configuration. Needed in case the presentation of the overlay changes depending on screen size. Note that this method is the only allowed way to update a configuration of an OverlayController instance. | cfgToAdd: OverlayConfig | ||
_handleAccessibility | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleBackdrop | protected | Sets up backdrop on the given overlay. If there was a backdrop on another element it is removed. Otherwise this is the first time displaying a backdrop, so a animation-in animation is played. | { phase }, config: { animation?: boolean, phase: OverlayPhase } | ||
_handleBlocking | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleFeatures | protected | All features are handled here. | { phase }, config: { phase: OverlayPhase } | ||
_handleHidesOnEsc | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleHidesOnOutsideClick | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleHidesOnOutsideEsc | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleInheritsReferenceWidth | protected | ||||
_handlePosition | protected | { phase }, config: { phase: OverlayPhase } | |||
_handlePreventsScroll | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleTrapsKeyboardFocus | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleVisibilityTriggers | protected | { phase }, config: { phase: OverlayPhase } | |||
_handleZIndex | protected | Display local overlays on top of elements with no z-index that appear later in the DOM | { phase }, config: { phase: OverlayPhase } | ||
_hasDisabledInvoker | protected | ||||
_init | protected | ||||
_keepBodySize | protected | { phase }, config: { phase: OverlayPhase } | |||
_restoreFocus | protected | ||||
_transitionHide | protected | { backdropNode, contentNode }, hideConfig: {backdropNode:HTMLElement, contentNode:HTMLElement} | |||
_transitionShow | protected | showConfig: {backdropNode:HTMLElement; contentNode:HTMLElement} |
Events
| Name | Type | Description | Inherited From |
|---|---|---|---|
show | Event | ||
hide | Event |
class: OverlayMixin
Fields
| Name | Privacy | Type | Default | Description | Inherited From |
|---|---|---|---|---|---|
config | public | Partial<OverlayConfig> | {} | Configure the many options of the `OverlayController` | |
opened | public | boolean | false | If you add the opened attribute a dialog will be opened on page load. The invoker can be left out in case the user does not need to be able to reopen the dialog. | |
_overlayBackdropNode | protected | ||||
_overlayContentNode | protected | ||||
_overlayContentWrapperNode | protected | ||||
_overlayInvokerNode | protected | ||||
_overlayReferenceNode | protected |
Methods
| Name | Privacy | Description | Parameters | Return | Inherited From |
|---|---|---|---|---|---|
close | public | Hides the overlay | |||
open | public | Shows the overlay | |||
repositionOverlay | public | Sometimes it’s needed to recompute Popper position of an overlay, for instance when we have an opened combobox and the surrounding context changes (the space consumed by the textbox increases vertically) | |||
toggle | public | Toggles the overlay | |||
_defineOverlay | protected | { contentNode, invokerNode, referenceNode, backdropNode, contentWrapperNode }, config: DefineOverlayConfig | OverlayController | ||
_defineOverlayConfig | protected | OverlayConfig | |||
_isPermanentlyDisconnected | protected | When we’re moving around in dom, disconnectedCallback gets called. Before we decide to teardown, let’s wait to see if we were not just moving nodes around. | Promise<boolean> | ||
_setOpenedWithoutPropertyEffects | protected | When the opened state is changed by an Application Developer,cthe OverlayController is requested to show/hide. It might happen that this request is not honoured (intercepted in before-hide for instance), so that we need to sync the controller state to this webcomponent again, preventing eternal loops. | newOpened: boolean | ||
_setupOpenCloseListeners | protected | ||||
_setupOverlayCtrl | protected | ||||
_teardownOpenCloseListeners | protected | ||||
_teardownOverlayCtrl | protected |
Events
| Name | Type | Description | Inherited From |
|---|---|---|---|
opened-changed | CustomEvent |
Attributes
| Name | Field | Inherited From |
|---|---|---|
opened | opened |
class: OverlaysManager
Fields
| Name | Privacy | Type | Default | Description | Inherited From |
|---|---|---|---|---|---|
list | public | no setter as .list is intended to be read-only You can use .add or .remove to modify it | |||
shownList | public | no setter as .shownList is intended to be read-only You can use .show or .hide on individual controllers to modify | |||
siblingsInert | public | Features right now only for Global Overlay Manager | |||
_siblingsInert | protected | boolean | false |
Methods
| Name | Privacy | Description | Parameters | Return | Inherited From |
|---|---|---|---|---|---|
add | public | Registers an overlay controller. | ctrlToAdd: OverlayController | OverlayController | |
hide | public | ctrlToHide: any | |||
remove | public | ctrlToRemove: OverlayController | |||
requestToEnableScroll | public | currentController: OverlayController | |||
requestToPreventScroll | public | PreventsScroll | |||
requestToShowOnly | public | Blocking | blockingCtrl: OverlayController | ||
retractRequestToShowOnly | public | blockingCtrl: OverlayController | |||
show | public | ctrlToShow: OverlayController | |||
teardown | public |