Keyboard activation dispatches a PointerEvent
The click that Command synthesizes for Enter and Space on an element that isn't natively clickable is now a PointerEvent built by the window that owns the element, reporting pointerId: -1 and an empty pointerType. That is what Chromium, Firefox, and WebKit dispatch for a click no pointer caused, so a handler reading event.pointerType or checking event instanceof PointerEvent now sees the same shape it sees on a native button.
<Ariakit.Button
render={<div />}
onClick={(event) => {
// After Enter or Space: was false, now true.
event.nativeEvent instanceof PointerEvent;
}}
/>This reaches every component built on Command: Button, Checkbox, Radio, CompositeItem, MenuItem, MenuItemCheckbox, MenuItemRadio, ComboboxItem, SelectItem, Tab, ToolbarItem, ToolbarContainer, Disclosure, DialogDisclosure, DialogDismiss, PopoverDisclosure, PopoverDismiss, HovercardDisclosure, HovercardDismiss, MenuButton, MenuDismiss, Select, SelectDismiss, ComboboxSelect, ComboboxCancel, ComboboxDisclosure, ComboboxDismiss, FormSubmit, FormReset, FormPush, FormRemove, FormCheckbox, and FormRadio.
Other updates
- Fixed
ComboboxItemso an explicitfocusOnHoverboolean or callback value neither activates an item on hover nor clears the active item on hover end while the combobox is closed. - Fixed
ComboboxListandComboboxPopover, which builds on it, not moving focus back to the combobox when the list itself receives focus and the document contains a form namedactiveElement. - Fixed keyboard activation on non-native
Commandelements and components built onCommand, such asButton, so their synthetic clicks use the element's owner window forviewand are composed. - Fixed
Compositeand components built on it, such asMenuandToolbar, building the events they synthesize with the outer window's constructors, so an item inside a same-origin iframe received events that failedinstanceofagainst that frame's own interfaces. - Fixed
Portaland components built on it, such asTooltip, as well asCombobox, when the document contains a form nameddefaultView. - Fixed
Dialogthrowing instead of opening when it renders a form with a control namedself,document, orownerDocument, and on Safari throwing before the dialog was ever opened, so the page failed without anyone interacting with it. - Fixed
Dialogand components built on it, such asPopoverandMenu, pulling focus back from an element the application focused outside them during placement when the document contains a form namedactiveElement. - Fixed
Focusableand components built on it, such asTabandButton, so a middle click no longer opens the destination of adisabledelement rendered as a link, including one kept reachable byaccessibleWhenDisabled, whichTabenables by default. - Fixed
Dialogand components built on it, such asPopoverandMenu, failing to return focus to the element that opened it when the document contains a form namedactiveElement. - Fixed
SelectItemso an authoredfocusOnHovercallback no longer runs while the select is closed, keeping its side effects from activating an item, changing the value, or moving focus in a collapsed always-visibleSelectList. Thanks to @waterWang. - Fixed
Tabnot receiving DOM focus when the selected tab changes while another tab holds focus and the document contains a form namedactiveElement. - Fixed
TooltipAnchor,HovercardAnchor, andMenuButtonto respect the resolveddisabledandaccessibleWhenDisabledstate on hover in any composition order. Thanks to @btzr-io and @mayank99. - Updated dependencies:
@ariakit/react-components@0.5.0