Element: <oj-popup>

Oracle® JavaScript Extension Toolkit (JET)
7.1.0

F18183-01

Signature:

class ojPopup

QuickNav

Attributes

JET Custom Elements

JET components are implemented as custom HTML elements. In addition to the component attributes documented in this page, JET components also support standard HTML global attributes like id and aria-label.

The JET data binding syntax can be used to define both component and global attributes through the use of dynamically evaluated expressions. All attributes (component and global) support attribute-level binding by prefixing the attribute name with ":" (e.g. :id="[...]"). When using attribute-level binding, all expression values are treated as strings. Additionally, component attributes support property-level binding by using the attribute name directly with no ":" prefix. When using property-level binding, the expressions should evaluate to the types documented by the corresponding attributes. Property-level binding is strongly recommended over attribute-level binding for component attributes.

A detailed description of working with custom HTML elements can be found in: JET Custom Element Usage.



PREVIEW: This is a preview API. Preview APIs are production quality, but can be changed on a major version without a deprecation path.

Version:
  • 7.1.0
Since:
  • 1.1.0
Module:
  • ojpopup

Module usage

See JET Module Loading for an overview of module usage within JET.

Typescript Import Format
//To typecheck the element APIs, import as below.
import {ojPopup} from "ojs/ojpopup";

//For the transpiled javascript to load the element's module, import as below
import "ojs/ojpopup";

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.


JET Popup Component

Description: Themeable, WAI-ARIA-compliant popup that can display arbitrary content.

A JET popup can be created from custom element <oj-popup> syntax. This element will become the root - outer chrome of the popup. The content of the popup will be relocated under an element marked with the .oj-popup-content selector. Dynamic content can be inserted under the element identified by the .oj-popup-content selector. However, page developers are encouraged to create their own content element to anchor dynamic content changes versus using .oj-popup-content as the marker selector.

<oj-popup id="popup">
  <span class="mycontent">
    Hello World!
  </span class="mycontent">
</oj-popup>

The following is an example of dynamically changing the content of the popup defined above.

var content = popup.querySelector( ".mycontent" );
content.textContent = "Hello Universe!";

Touch End User Information

Target Gesture Action
Outside popup or launcher Tap Close the popup.

Disabled items do not allow any touch interaction.

Keyboard End User Information

Target Key Action
Focus within Popup Tab or Shift + Tab Navigate the content of the popup. Close the open popup if there are no tab stops in the popup.
F6 Move focus to the launcher for a popup with modeless modality. Close the open popup if the modality is modal.
Esc Close the open popup.
Popup Launcher F6 Move focus to the first tab stop within the open popup. If there is not a tab stop within the content, focus is established on the popup.


Accessibility

For WAI-ARIA compliance, JET automatically adds role="tooltip" to the root popup dom element if not already specificed. This is not a component property but rather the standard html role attribute. Depending on how the popup is used in the page, the page developer should choose from the following:

  • "tooltip" defines contextual popup that displays a description for an element.
  • "dialog" defines an application window that is designed to interrupt the current processing of an application in order to prompt the user to enter information or require a response.
  • "alertdialog" defines type of dialog that contains an alert message, where initial focus goes to an element within the dialog.
The popup also adds the aria-describedby="popup-id" attribute to the assocaited launcher while the popup is open.

On platforms that support voice over mode (VO), the popup injects anchor tags "skip links" into the document for navigation. Skip links are not visible but read in VO mode. Two skip links are injected into the document when a popup is disclosed:
  • A close link, oj.ojPopup#translations.ariaCloseSkipLink, is injected as a sibling to the popup's content. Activation of this link will close the popup.
  • For cases where the popup doesn't steal focus when it's open, a content navigation skip link, oj.ojPopup#translations.ariaFocusSkipLink, is injected as a sibling to the launcher (first required argument of the open method). If the launcher selector targets a sub-element of the launcher, the skip link could be injected under the launcher, which can be problematic for oj-button as skip link activation will also activate the associated launcher.

One point often overlooked is making the gestures that launch a popup accessible. There are no constraints to what events a page developer might choose to trigger opening a popup. The choice should be accessible for screen reader users. Page developers should take care when using mouse events to trigger opening of a popup. This is especially important if the content of the popup can't be derived from other visible areas on the page. In cases that mouseover, mouseout, mouseenter, mouseleave and hover events are used to launch popups, there needs to be a keyboard functional equivalency.

See also the oj-focus-highlight discussion.

Reparenting

When popups are open, they will be reparented in the document and reparented back when closed. When open, the location of the popup within the document will be in context of how it's used. Popups open from other popups will be relocated in the document into the nearest parent popup's layer. The popups layer defines its z-index weight "stacking context". The ojPopup's layer is marked with the "oj-popup-layer" style. The context of opening is defined by the launcher argument passed to the open method. If not open from another popup, the popup will be reparented to a container in the document body. Popups of the same type are assigned the same z-index values. The layering between peer popups reflect the opening order. The popup that has active focus will be assigned a greater z-index value. This is applied to the popup's layer by way of the "oj-focus-within" pseudo selector applied with "oj-popup-layer" selector. The page author has control over z-index weights by way of the "oj-popup-layer" selector.

There are known caveats with this design. However, these scenarios are considered "bad use" based on our JET popup strategy.

  1. Events raised within the popup will not bubble up to the popup's original ancestors. Instead, listeners for popup events should be applied to either the popup's root element, or the document.
  2. Likewise, developers should not use CSS descendant selectors, or similar logic, that assumes that the popup will remain a child of its original parent.
  3. Popups containing iframes are problematic. The iframe elements "may" fire a HTTP GET request for its src attribute each time the iframe is reparented in the document.
  4. If an iframe is added to the popup's content, it must not be the first or last tab stop within the popup or keyboard and VoiceOver navigation will not remain within the popup.
  5. In some browsers, reparenting a popup that contains elements having overflow, will cause these overflow elements to reset their scrollTop.

Styling

The following CSS classes can be applied by the page author as needed.

Class Description Example
oj-focus-highlight Under normal circumstances this class is applied automatically. It is documented here for the rare cases that an app developer needs per-instance control.

The oj-focus-highlight class applies focus styling that may not be desirable when the focus results from pointer interaction (touch or mouse), but which is needed for accessibility when the focus occurs by a non-pointer mechanism, for example keyboard or initial page load.

The application-level behavior for this component is controlled in the theme by the $focusHighlightPolicy SASS variable; however, note that this same variable controls the focus highlight policy of many components and patterns. The values for the variable are:

  • nonPointer: oj-focus-highlight is applied only when focus is not the result of pointer interaction. Most themes default to this value.
  • all: oj-focus-highlight is applied regardless of the focus mechanism.
  • none: oj-focus-highlight is never applied. This behavior is not accessible, and is intended for use when the application wishes to use its own event listener to precisely control when the class is applied (see below). The application must ensure the accessibility of the result.

To change the behavior on a per-instance basis, the application can set the SASS variable as desired and then use event listeners to toggle this class as needed.

<oj-popup class="oj-focus-highlight">
 <input id="blueopt" type="checkbox" value="blue">
 <label for="blueopt">Blue</label>
</oj-popup>

Event Handling

  • ojBeforeClose(event) - Triggered before a popup closes. Event can prevent closing the popup; However, there are cases the framework must veto, such as when the popup is destroyed.
  • ojBeforeOpen(event) - Triggered before a popup opens. Event can prevent opening the popup.
  • ojClose(event) - Triggered after the popup has closed.
  • ojFocus(event) - Triggered when initial focus is established on opening, depending on the value of the initalFocus property, or F6 focus toggle from the associated launcher.
  • ojOpen(event) - Triggered after the popup has been made visible.

Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.

Slots

JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.

contextMenu

The contextMenu slot is set on the oj-menu within this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.

The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.

To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc of the individual components for details.

Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.

Attributes

auto-dismiss :"none"|"focusLoss"

Defines conditions that will cause an open popup to auto close dismiss. A value of focusLoss defines the dismissal condition where focus has left the content of the popup or from the associated launcher or if what the popup is aligned to is not fully visible within an overflow area.
Supported Values:
Value Description
"focusLoss" defines auto dismissal behavior when focus leaves the content of the popup or associated launcher. In addition, if what the popup is positioned to is not visible within an overflow area, the popup will auto close dismiss.
"none" disables auto dismissal behaviors.
Default Value:
  • 'focusLoss'
Names
Item Name
Property autoDismiss
Property change event autoDismissChanged
Property change listener attribute (must be of type function) on-auto-dismiss-changed

chrome :"default"|"none"

Defines the presence of border, shadow and background color of the root popup dom. Value of none applies the oj-popup-no-chrome selector defined by the active theme to the root dom of the popup to remove the default chrome.
Supported Values:
Value Description
"default" describes the popups border, shadow, and background color defined by the active theme.
"none" turns off the outer chrome defined by the active theme.
Default Value:
  • 'default'
Names
Item Name
Property chrome
Property change event chromeChanged
Property change listener attribute (must be of type function) on-chrome-changed

initial-focus :"auto"|"none"|"firstFocusable"|"popup"

Determines if the popup should steal focus to its content when initially open. A value of none prevents the popup from grabbing focus when open.
Supported Values:
Value Description
"auto" is derived from the values of the modality and autoDismiss properties
"firstFocusable" defines that a popup should grab focus to the first focusable element within the popup's content.
"none" prevents the popup from stealing focus when open.
"popup" focus to the root popup container (good choice for touch platforms).
Default Value:
  • 'auto'
Names
Item Name
Property initialFocus
Property change event initialFocusChanged
Property change listener attribute (must be of type function) on-initial-focus-changed

modality :"modeless"|"modal"

Determines if the popup should block user input of the page behind with a blocking overlay pane.

The default modality varies by theme. Each theme can set its default by setting $popupModalityOptionDefault.

Supported Values:
Value Description
"modal" The popup is modal. Interactions with other page elements are disabled. Modal popups overlay other page elements.
"modeless" defines a modeless popup.
Default Value:
  • 'modeless'
Names
Item Name
Property modality
Property change event modalityChanged
Property change listener attribute (must be of type function) on-modality-changed

position :oj.ojPopup.Position

Position property is used to establish the location the popup will appear relative to another element. oj.ojPopup.Position defines "my" alignment "at" the alignment "of" some other thing which can be "offset" by so many pixels.

The "my" and "at" properties defines aligment points relative to the popup and other element. The "my" property represents the popups alignment where the "at" property represents the other element that can be identified by "of" or defauts to the launcher when the popup opens. The values of these properties describe horizontal and vertical alignments.

Deprecated v3.0.0 jQuery UI position syntax; Use of a percent unit with "my" or "at" is not supported.
Names
Item Name
Property position
Property change event positionChanged
Property change listener attribute (must be of type function) on-position-changed

position.at :Object

Defines which position on the target element ("of") to align the positioned element against.
Names
Item Name
Property position.at

position.at.horizontal :"start"|"end"|"left"|"center"|"right"

Defines the horizontal alignment of what the popup is aligned to.
Supported Values:
Value Description
"center"
"end" evaluates to "right" in LTR mode and "left" in RTL mode.
"left"
"right"
"start" evaluates to "left" in LTR mode and "right" in RTL mode.
Default Value:
  • 'start'
Names
Item Name
Property position.at.horizontal

position.at.vertical :"top"|"center"|"bottom"

Defines the vertical alignment of what the popup is aligned to.
Supported Values:
Value
"bottom"
"center"
"top"
Default Value:
  • 'bottom'
Names
Item Name
Property position.at.vertical

position.collision :"flip"|"fit"|"flipfit"|"flipcenter"|"none"

Rule for alternate alignment.
Supported Values:
Value Description
"fit" shift the element away from the edge of the window.
"flip" the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.
"flipcenter" first applies the flip rule and follow with center alignment.
"flipfit" first applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.
"none" no collision detection.
Default Value:
  • 'flip'
Names
Item Name
Property position.collision

position.my :Object

Defines which edge on the popup to align with the target ("of") element.
Names
Item Name
Property position.my

position.my.horizontal :"start"|"end"|"left"|"center"|"right"

Defines the horizontal alignment of the popup.
Supported Values:
Value Description
"center"
"end" evaluates to "right" in LTR mode and "left" in RTL mode.
"left"
"right"
"start" evaluates to "left" in LTR mode and "right" in RTL mode.
Default Value:
  • 'start'
Names
Item Name
Property position.my.horizontal

position.my.vertical :"top"|"center"|"bottom"

Defines the vertical alignment of the popup.
Supported Values:
Value
"bottom"
"center"
"top"
Default Value:
  • 'top'
Names
Item Name
Property position.my.vertical

position.of :string|Object

Which element to position the popup against. The default is the launcher argument passed to the open method. If the value is a string, it should be a selector or the literal string value of window. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.
Names
Item Name
Property position.of

position.offset :Object

Defines a point offset in pixels from the ("my") alignment.
Names
Item Name
Property position.offset

position.offset.x :number

Horizontal aligment offset.
Default Value:
  • 0
Names
Item Name
Property position.offset.x

position.offset.y :number

Vertical alignment offset.
Default Value:
  • 0
Names
Item Name
Property position.offset.y

tail :"none"|"simple"

Determines if a decoration will be displayed from the popup that points to the element the popup is aligned to. The simple value enables the tail defined by the current theme. In addtion, the oj-popup-tail-simple selector will be applied to the root dom element. This is to allow the box-shadow, z-index and other chrome styling to vary per tail decoration.
Supported Values:
Value Description
"none" no decoration will be displayed from the popup pointing to the launcher.
"simple" enables showing the tail defined by the current theme.
Default Value:
  • 'none'
Names
Item Name
Property tail
Property change event tailChanged
Property change listener attribute (must be of type function) on-tail-changed

translations :object|null

A collection of translated resources from the translation bundle, or null if this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.

If the component does not contain any translatable resource, the default value of this attribute will be null. If not, an object containing all resources relevant to the component.

If this component has translations, their documentation immediately follows this doc entry.

Names
Item Name
Property translations
Property change event translationsChanged
Property change listener attribute (must be of type function) on-translations-changed

Label assigned to a hidden anchor tag used for accessibility navigation on platforms supporting VoiceOver. The link is injected as a sibling to the context area of an open popup and used for oj.ojPopup#close activation.

Default Value:
  • "Double tap to close the open pop-up."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaCloseSkipLink

Label assigned to a hidden anchor tag used for accessibility navigation on platforms supporting VoiceOver. The link is injected as a sibling to the launcher of an open popup. The launcher is passed as the first argument to oj.ojPopup#open. Activation of the link will move focus to the content of the associated popup.

Default Value:
  • "Double tap to navigate to the open pop-up."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaFocusSkipLink

(nullable) translations.aria-live-region-initial-focus-first-focusable :string

Message announced to a wai-aria live region on desktop platforms when a popup opens and steals initial focus.

Default Value:
  • "Entering pop-up. Press F6 to navigate between the pop-up and associated control."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaLiveRegionInitialFocusFirstFocusable

(nullable) translations.aria-live-region-initial-focus-first-focusable-touch :string

Message announced to a wai-aria live region on platforms supporting VoiceOver when a popup opens and steals initial focus.

Default Value:
  • "Entering pop-up. Pop-up can be closed by navigating to the last link within the pop-up."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaLiveRegionInitialFocusFirstFocusableTouch

(nullable) translations.aria-live-region-initial-focus-none :string

Message announced to a wai-aria live region on desktop platforms when a popup opens but doesn't change focus.

Default Value:
  • "Pop-up opened. Press F6 to navigate between the pop-up and associated control."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaLiveRegionInitialFocusNone

(nullable) translations.aria-live-region-initial-focus-none-touch :string

Message announced to a wai-aria live region on platforms supporting VocieOver when a popup opens but doesn't change focus.

Default Value:
  • "Pop-up opened. Navigate to the next link to establish focus within the pop-up."
Since:
  • 6.0.0
See:
Names
Item Name
Property translations.ariaLiveRegionInitialFocusNoneTouch

Events

ojAnimateEnd

Triggered when a default animation has ended, such as when the component is being opened/closed or a child item is being added/removed. This event is not triggered if the application has called preventDefault on the animateStart event.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Argument Description
element Element <not nullable>
target of animation
action "open" | "close" The action that is ending the animation. The number of actions can vary from component to component. Suggested values are:
  • "open" - when a popup component is opened
  • "close" - when a popup component is closed

ojAnimateStart

Triggered when a default animation is about to start, such as when the component is being opened/closed or a child item is being added/removed. The default animation can be cancelled by calling event.preventDefault.
Properties:

All of the event payloads listed below can be found under event.detail.

Name Type Argument Description
action "open" | "close" The action that is starting the animation. The number of actions can vary from component to component. Suggested values are:
  • "open" - when a popup component is opened
  • "close" - when a popup component is closed
element Element <not nullable>
target of animation
endCallback function():void <not nullable>
If the event listener calls event.preventDefault to cancel the default animation, It must call the endCallback function when it finishes its own animation handling and any custom animation has ended.

ojBeforeClose

Triggered before the popup is dismissed via the close() method. The close can be cancelled by calling event.preventDefault().

ojBeforeOpen

Triggered before the popup is launched via the open() method. The open can be cancelled by calling event.preventDefault().

ojClose

Triggered after the popup is dismissed via the close() method.

ojFocus

Triggered after focus has been transfered to the popup. This will occur after the open() method is called, depending on the value of the initialFocus property. It's also triggered when using the F6 key to toggle focus from the associated launcher element to the content of the popup.

ojOpen

Triggered after the popup is launched via the open() method.

Methods

close() → {void}

Closes the popup. This method does not accept any arguments.
Fires:
  • oj.ojPopup#event:ojBeforeClose
  • oj.ojPopup#event:ojAnimationStart
  • oj.ojPopup#event:ojAnimationEnd
  • oj.ojPopup#event:ojClose
Returns:
Type
void

getProperty(property) → {any}

Retrieves the value of a property or a subproperty. The return type will be the same as the type of the property as specified in this API document. If the method is invoked with an incorrect property/subproperty name, it returns undefined.
Parameters:
Name Type Description
property string The property name to get. Supports dot notation for subproperty access.
Since:
  • 4.0.0
Returns:
Type
any
Example

Get a single subproperty of a complex property:

let subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2');

isOpen() → {boolean}

Returns the state of whether the popup is currently open. This method does not accept any arguments.

The "open" state reflects the period of time the popup is visible, including open and close animations.
Returns:
true if the popup is open.
Type
boolean

open(launcher, position) → {void}

Opens the popup. This method accepts two arguments. The first argument "launcher" is required but the second "position" is optional.
Parameters:
Name Type Argument Description
launcher string | Element <not nullable>
selector or dom element that is associated with the popup. Defines the context of how the popup is used. The argument is required.
position oj.ojPopup.Position <optional>
oj.ojPopup.Position an element relative to another
Fires:
  • oj.ojPopup#event:ojBeforeOpen
  • oj.ojPopup#event:ojAnimationStart
  • oj.ojPopup#event:ojAnimationEnd
  • oj.ojPopup#event:ojOpen
Returns:
Type
void

refresh() → {void}

Causes the popup to reevaluate its position. Call this function after the content of the popup has dynamically changed while the popup is open.

This method does not accept any arguments.

Returns:
Type
void

setProperties(properties) → {void}

Performs a batch set of properties. The type of value for each property being set must match the type of the property as specified in this API document.
Parameters:
Name Type Description
properties Object An object containing the property and value pairs to set.
Since:
  • 4.0.0
Returns:
Type
void
Example

Set a batch of properties:

myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"});

setProperty(property, value) → {void}

Sets a property or a subproperty (of a complex property) and notifies the component of the change, triggering a [property]Changed event. The value should be of the same type as the type of the attribute mentioned in this API document.
Parameters:
Name Type Description
property string The property name to set. Supports dot notation for subproperty access.
value any The new value to set the property to.
Since:
  • 4.0.0
Returns:
Type
void
Example

Set a single subproperty of a complex property:

myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");

Type Definitions

Position

Properties:
Name Type Argument Description
my oj.ojPopup.PositionAlign <optional>
Defines which edge on the popup to align with the target ("of") element.
at oj.ojPopup.PositionAlign <optional>
Defines which position on the target element ("of") to align the positioned element against.
offset oj.ojPopup.PositionPoint <optional>
Defines a point offset in pixels from the ("my") alignment.
of string | oj.ojPopup.PositionPoint <optional>
Which element to position the popup against. The default is the launcher argument passed to the open method.

If the value is a string, it should be a selector or the literal string value of window. Otherwise, a point of x,y. When a point is used, the values are relative to the whole document. Page horizontal and vertical scroll offsets need to be factored into this point - see UIEvent pageX, pageY.

collision "flip" | "fit" | "flipfit" | "flipcenter" | "none" <optional>
Rule for alternate alignment.

  • "flip" the element to the opposite side of the target and the collision detection is run again to see if it will fit. Whichever side allows more of the element to be visible will be used.
  • "fit" shift the element away from the edge of the window.
  • "flipfit" first applies the flip logic, placing the element on whichever side allows more of the element to be visible. Then the fit logic is applied to ensure as much of the element is visible as possible.
  • flipcenter first applies the flip rule and follows with center alignment.
  • "none" no collision detection.

PositionAlign

Properties:
Name Type Argument Description
vertical "top" | "bottom" | "center" <optional>
Vertical alignment.
horizontal "start" | "end" | "left" | "center" | "bottom" <optional>
Horizontal alignment.

  • "start" evaluates to "left" in LTR mode and "right" in RTL mode.
  • "end" evaluates to "right" in LTR mode and "left" in RTL mode.

PositionPoint

Properties:
Name Type Argument Description
x number <optional>
Horizontal aligment offset.
y number <optional>
Vertical alignment offset.