Usage
Signature:
interface PopupElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { PopupElement } from "ojs/ojpopup";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojpopup";
For additional information visit:
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.
Styling Classes
-
.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.
Example
<oj-popup class="oj-focus-highlight"> <!-- Content --> </oj-popup>
-
CSS Variables
Name | Type | Description |
---|---|---|
--oj-popup-bg-color |
<color> | Popup background color |
--oj-popup-border-color |
<color> | Popup border color |
--oj-popup-border-radius |
<length> | <percentage> | Popup border radius |
--oj-popup-box-shadow |
Popup box shadow | |
--oj-popup-padding |
<length> | Popup padding |
--oj-popup-tail-height |
<length> | Popup tail height |
--oj-popup-tail-width |
<length> | Popup tail width |
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.
-
Default
-
The
<oj-popup>
accepts any DOM elements in its Default slot but only tracks the validity state of any JET custom element descendents that contain the valid property. -
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.
- Deprecated:
-
Since Description 13.0.0
This web component no longer supports launching a context menu.
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.- Default Value:
'focusLoss'
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. Names
Item Name Property autoDismiss
Property change event autoDismissChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) 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 theoj-popup-no-chrome
selector defined by the active theme to the root dom of the popup to remove the default chrome.- Deprecated:
-
Since Description 17.0.0
This is not recommended in the Redwood design system.
- Default Value:
'default'
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. Names
Item Name Property chrome
Property change event chromeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) 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.- Default Value:
'auto'
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). Names
Item Name Property initialFocus
Property change event initialFocusChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) 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.
- Default Value:
'modeless'
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. Names
Item Name Property modality
Property change event modalityChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) 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 alignment 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, see Events and Listeners for additional information.) 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.
- Default Value:
'start'
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. Names
Item Name Property position.at.horizontal
-
position.at.vertical :"top"|"center"|"bottom"
-
Defines the vertical alignment of what the popup is aligned to.
- Default Value:
'bottom'
Supported Values:
Value bottom
center
top
Names
Item Name Property position.at.vertical
-
position.collision :"flip"|"fit"|"flipfit"|"flipcenter"|"none"
-
Rule for alternate alignment.
- Default Value:
'flip'
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. 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.
- Default Value:
'start'
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. Names
Item Name Property position.my.horizontal
-
position.my.vertical :"top"|"center"|"bottom"
-
Defines the vertical alignment of the popup.
- Default Value:
'top'
Supported Values:
Value bottom
center
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 theopen
method. If the value is a string, it should be a selector or the literal string value ofwindow
. 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 alignment 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, theoj-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.- Default Value:
'none'
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. Names
Item Name Property tail
Property change event tailChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) 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, see Events and Listeners for additional information.) on-translations-changed
-
(nullable) translations.aria-close-skip-link :string
-
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
-
(nullable) translations.aria-focus-skip-link :string
-
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 VoiceOver 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.
- Deprecated:
-
Since Description 12.1.0
This web component no longer supports this event.
- "open" - when a popup component is opened
- "close" - when a popup component is closed
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type Argument Description action
"open" | "close" The action that triggered the animation.
The number of actions can vary from component to component. Suggested values are:element
Element <not nullable>
target of animation -
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
.- Deprecated:
-
Since Description 12.1.0
This web component no longer supports this event.
- "open" - when a popup component is opened
- "close" - when a popup component is closed
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type Argument Description action
"open" | "close" The action that triggers the animation.
The number of actions can vary from component to component. Suggested values are: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 callingevent.preventDefault()
.See Events and Listeners for additional information.
-
ojBeforeOpen
-
Triggered before the popup is launched via the
open()
method. The open can be cancelled by callingevent.preventDefault()
.See Events and Listeners for additional information.
-
ojClose
-
Triggered after the popup is dismissed via the
close()
method.See Events and Listeners for additional information.
-
ojFocus
-
Triggered after focus has been transferred to the popup. This will occur after the
open()
method is called, depending on the value of theinitialFocus
property. It's also triggered when using the F6 key to toggle focus from the associated launcher element to the content of the popup.See Events and Listeners for additional information.
-
ojOpen
-
Triggered after the popup is launched via the
open()
method.See Events and Listeners for additional information.
Methods
-
close : {void}
-
Closes the popup. This method does not accept any arguments.
Fires:
- oj.ojPopup#event:ojBeforeClose
- 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
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: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
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
myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");
Type Definitions
-
Position
-
- "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.
Properties:
Name Type Argument Description at
oj.ojPopup.PositionAlign <optional>
Defines which position on the target element ("of") to align the positioned element against. collision
"flip" | "fit" | "flipfit" | "flipcenter" | "none" <optional>
Rule for alternate alignment. my
oj.ojPopup.PositionAlign <optional>
Defines which edge on the popup to align with the target ("of") element. of
string | oj.ojPopup.PositionPoint <optional>
Which element to position the popup against. The default is the launcher
argument passed to theopen
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.offset
oj.ojPopup.PositionPoint <optional>
Defines a point offset in pixels from the ("my") alignment. -
PositionAlign
-
- "start" evaluates to "left" in LTR mode and "right" in RTL mode.
- "end" evaluates to "right" in LTR mode and "left" in RTL mode.
Properties:
Name Type Argument Description horizontal
"start" | "end" | "left" | "center" | "right" <optional>
Horizontal alignment. vertical
"top" | "bottom" | "center" <optional>
Vertical alignment. -
PositionPoint
-
Properties:
Name Type Argument Description x
number <optional>
Horizontal alignment offset. y
number <optional>
Vertical alignment offset.