Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial review: Document popover="hint" #37990

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The **`popoverTargetElement`** property of the {{domxref("HTMLButtonElement")}}

It is the JavaScript equivalent of the [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) HTML attribute.

Establishing a relationship between a popover and its invoker button using the `popoverTargetElement` property has two additional useful effects:

- The browser creates an implicit [`aria-details`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-details) and [`aria-expanded`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded) relationship between popover and invoker, and places the popover in a logical position in the keyboard focus navigation order when shown. This makes the popover more accessible to keyboard and assistive technology (AT) users (see also [Popover accessibility features](/en-US/docs/Web/API/Popover_API/Using#popover_accessibility_features)).
- The browser creates an implicit anchor reference between the two, making it very convenient to position popovers relative to their controls using [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning). See [Implicit popover anchor associations](/en-US/docs/Web/API/Popover_API/Using#implicit_popover_anchor_associations) for more details.

## Value

A reference to a popover element in the DOM.
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/htmlelement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ _Also inherits properties from its parent, {{DOMxRef("Element")}}._
As a getter, it is the same as {{DOMxRef("HTMLElement.innerText")}} (it represents the rendered text content of an element and its descendants).
As a setter, it replaces the selected node and its contents with the given value, converting any line breaks into {{HTMLElement("br")}} elements.
- {{domxref("HTMLElement.popover")}}
- : Gets and sets an element's popover state via JavaScript (`"auto"` or `"manual"`), and can be used for feature detection. Reflects the value of the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) global HTML attribute.
- : Gets and sets an element's popover state via JavaScript (`"auto"`, `"hint"`, or `"manual"`), and can be used for feature detection. Reflects the value of the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) global HTML attribute.
- {{DOMxRef("HTMLElement.spellcheck")}}
- : A boolean value that controls the [spell-checking](/en-US/docs/Web/HTML/Global_attributes/spellcheck) hint. It is available on all HTML elements, though it doesn't affect all of them.
- {{DOMxRef("HTMLElement.style")}}
Expand Down
25 changes: 18 additions & 7 deletions files/en-us/web/api/htmlelement/popover/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,31 @@ browser-compat: api.HTMLElement.popover

{{APIRef("Popover API")}}

The **`popover`** property of the {{domxref("HTMLElement")}} interface gets and sets an element's popover state via JavaScript (`"auto"` or `"manual"`), and can be used for feature detection.
The **`popover`** property of the {{domxref("HTMLElement")}} interface gets and sets an element's popover state via JavaScript (`"auto"`, `"hint"`, or `"manual"`), and can be used for feature detection.

It reflects the value of the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) global HTML attribute.

## Value

An enumerated value; possible values are:

- `"auto"`: In [auto state](/en-US/docs/Web/API/Popover_API/Using#auto_state_and_light_dismiss):
- The popover can be "light dismissed" — this means that you can hide the popover by clicking outside it or pressing the <kbd>Esc</kbd> key.
- Usually, only one popover can be shown at a time — showing a second popover when one is already shown will hide the first one. The exception to this rule is when you have nested auto popovers. See [Nested popovers](/en-US/docs/Web/API/Popover_API/Using#nested_popovers) for more details.
- `"manual"`: In [manual state](/en-US/docs/Web/API/Popover_API/Using#using_manual_popover_state):
- The popover cannot be "light dismissed", although declarative show/hide/toggle buttons will still work.
- Multiple independent popovers can be shown at a time.
- `"auto"`

- : [`auto`](/en-US/docs/Web/API/Popover_API/Using#auto_state_and_light_dismiss) popovers can be "light dismissed" — this means that you can hide the popover by clicking outside it or pressing the <kbd>Esc</kbd> key.

Usually, only one `auto` popover can be shown at a time — showing a second popover when one is already shown will hide the first one. The exception to this rule is when you have nested auto popovers. See [Nested popovers](/en-US/docs/Web/API/Popover_API/Using#nested_popovers) for more details.

- `"hint"`

- : [`hint`](/en-US/docs/Web/API/Popover_API/Using#using_hint_popover_state) popovers do not close `auto` popovers when they are displayed, but will close other hint popovers.
They can be light dismissed and will respond to close requests.

Usually they are shown and hidden in response to non-click JavaScript events such as [`mouseover`](/en-US/docs/Web/API/Element/mouseover_event)/[`mouseout`](/en-US/docs/Web/API/Element/mouseout_event) and [`focus`](/en-US/docs/Web/API/Element/focus_event)/[`blur`](/en-US/docs/Web/API/Element/blur_event).
Clicking a button to open a `hint` popover would cause an open `auto` popover to light-dismiss.

- `"manual"`

- : [`manual`](/en-US/docs/Web/API/Popover_API/Using#using_manual_popover_state) popovers cannot be "light dismissed" are not automatically closed. Popovers must explicitly be displayed and closed using declarative show/hide/toggle buttons or JavaScript. Multiple independent `manual` popovers can be shown simultaneously.

## Examples

Expand Down
12 changes: 11 additions & 1 deletion files/en-us/web/api/htmlelement/showpopover/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ When `showPopover()` is called on an element with the [`popover`](/en-US/docs/We

```js-nolint
showPopover()
showPopover(options)
```

### Parameters

None.
- `options` {{optional_inline}}

- : An object that can contain the following properties:

- `source` {{optional_inline}}

- : An {{domxref("HTMLElement")}} reference; programmatically defines the invoker of the popover associated with the show action, that is, its control element. Establishing a relationship between a popover and its invoker using the `source` option has two useful effects:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also should do a focus order fixup to put the popover next in the tab order from the source element. This is currently not implemented in Chromium. As such the Browser Compat Data should maybe be marked as a partial implementation? cc @mfreed7 to see what he thinks regarding this.

Copy link
Contributor

@lukewarlow lukewarlow Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdn/browser-compat-data#25964 - I made a BCD PR to add Safari Tech Preview as partial (due to same bug) and also marked chrome as partial. Happy to change if people think it shouldn't be partial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably makes sense.

- The browser places the popover in a logical position in the keyboard focus navigation order when shown. This makes the popover more accessible to keyboard users (see also [Popover accessibility features](/en-US/docs/Web/API/Popover_API/Using#popover_accessibility_features)).
- The browser creates an implicit anchor reference between the two, making it very convenient to position popovers relative to their controls using [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning). See [Implicit popover anchor associations](/en-US/docs/Web/API/Popover_API/Using#implicit_popover_anchor_associations) for more details.

### Return value

Expand Down
18 changes: 17 additions & 1 deletion files/en-us/web/api/htmlelement/togglepopover/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,31 @@ When `togglePopover()` is called on an element with the [`popover`](/en-US/docs/
## Syntax

```js-nolint
togglePopover()
togglePopover(force)
togglePopover(options)
```

### Parameters

- `force`
A boolean (`force`) or an options object:

- `force` {{optional_inline}}
- : A boolean, which causes `togglePopover()` to behave like {{domxref("HTMLElement.showPopover", "showPopover()")}} or {{domxref("HTMLElement.hidePopover", "hidePopover()")}}, except that it doesn't throw an exception if the popover is already in the target state.
- If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens.
- If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens.
- `options` {{optional_inline}}

- : An object that can contain the following properties:

- `force` {{optional_inline}}
- : A boolean; see the `force` description above.
- `source` {{optional_inline}}

- : An {{domxref("HTMLElement")}} reference; programmatically defines the invoker of the popover associated with the toggle action, that is, its control element. Establishing a relationship between a popover and its invoker using the `source` option has two useful effects:

- The browser places the popover in a logical position in the keyboard focus navigation order when shown. This makes the popover more accessible to keyboard users (see also [Popover accessibility features](/en-US/docs/Web/API/Popover_API/Using#popover_accessibility_features)).
- The browser creates an implicit anchor reference between the two, making it very convenient to position popovers relative to their controls using [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning). See [Implicit popover anchor associations](/en-US/docs/Web/API/Popover_API/Using#implicit_popover_anchor_associations) for more details.

### Return value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The **`popoverTargetElement`** property of the {{domxref("HTMLInputElement")}} i

It is the JavaScript equivalent of the [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) HTML attribute.

Establishing a relationship between a popover and its invoker button using the `popoverTargetElement` property has two additional useful effects:

- The browser creates an implicit [`aria-details`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-details) and [`aria-expanded`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded) relationship between popover and invoker, and places the popover in a logical position in the keyboard focus navigation order when shown. This makes the popover more accessible to keyboard and assistive technology (AT) users (see also [Popover accessibility features](/en-US/docs/Web/API/Popover_API/Using#popover_accessibility_features)).
- The browser creates an implicit anchor reference between the two, making it very convenient to position popovers relative to their controls using [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning). See [Implicit popover anchor associations](/en-US/docs/Web/API/Popover_API/Using#implicit_popover_anchor_associations) for more details.

## Value

A reference to a popover element in the DOM.
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/popover_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ See [Using the popover API](/en-US/docs/Web/API/Popover_API/Using) for a detaile
## HTML attributes

- [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover)
- : A global attribute that turns an element into a popover element; takes a popover state (`"auto"` or `"manual"`) as its value.
- : A global attribute that turns an element into a popover element; takes a popover state (`"auto"`, `"hint"`, or `"manual"`) as its value.
- [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget)
- : Turns a {{htmlelement("button")}} or {{htmlelement("input")}} element into a popover control button; takes the ID of the popover element to control as its value.
- [`popovertargetaction`](/en-US/docs/Web/HTML/Element/button#popovertargetaction)
Expand All @@ -64,7 +64,7 @@ See [Using the popover API](/en-US/docs/Web/API/Popover_API/Using) for a detaile
### Instance properties

- {{domxref("HTMLElement.popover")}}
- : Gets and sets an element's popover state via JavaScript (`"auto"` or `"manual"`), and can be used for feature detection. Reflects the value of the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) global HTML attribute.
- : Gets and sets an element's popover state via JavaScript (`"auto"`, `"hint"`, or `"manual"`), and can be used for feature detection. Reflects the value of the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) global HTML attribute.
- {{domxref("HTMLButtonElement.popoverTargetElement")}} and {{domxref("HTMLInputElement.popoverTargetElement")}}
- : Gets and sets the popover element being controlled by the control button. The JavaScript equivalent of the [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) HTML attribute.
- {{domxref("HTMLButtonElement.popoverTargetAction")}} and {{domxref("HTMLInputElement.popoverTargetAction")}}
Expand Down
Loading