@deque/cauldron-react 7.1.0-canary.d4fda8b7 → 7.1.0-canary.df3401c2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type ActionListSelectionType, type onActionCallbackFunction } from './ActionListContext';
3
- interface ActionListProps extends React.HTMLAttributes<HTMLUListElement> {
3
+ interface ActionListProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'defaultValue' | 'onSelect'> {
4
4
  children: React.ReactNode;
5
5
  /** Limits the amount of selections that can be made within an action list */
6
6
  selectionType?: ActionListSelectionType | null;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ListboxOption } from './ListboxContext';
3
3
  import type { ListboxValue } from './ListboxOption';
4
- import type { PolymorphicProps, PolymorphicComponent } from '../../utils/polymorphicComponent';
4
+ import type { PolymorphicProps, PolymorphicComponentProps } from '../../utils/polymorphicComponent';
5
5
  interface BaseListboxProps extends PolymorphicProps<Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultValue'>> {
6
6
  navigation?: 'cycle' | 'bound';
7
7
  focusStrategy?: 'lastSelected' | 'first' | 'last';
@@ -30,5 +30,10 @@ interface MultiSelectListboxProps extends BaseListboxProps {
30
30
  value: ListboxValue[];
31
31
  }) => void;
32
32
  }
33
- declare const Listbox: PolymorphicComponent<SingleSelectListboxProps | MultiSelectListboxProps>;
33
+ type ListboxComponent = Omit<React.ForwardRefExoticComponent<SingleSelectListboxProps | MultiSelectListboxProps>, keyof CallableFunction> & {
34
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<MultiSelectListboxProps, T>): React.ReactElement | null;
35
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps, T>): React.ReactElement | null;
36
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps | MultiSelectListboxProps, T>): React.ReactElement | null;
37
+ };
38
+ declare const Listbox: ListboxComponent;
34
39
  export default Listbox;
package/lib/index.js CHANGED
@@ -4323,6 +4323,17 @@ var Combobox = React.forwardRef(function (_a, ref) {
4323
4323
  return value === lastSelectedValue;
4324
4324
  }) || [], 2), element = _a[0], option = _a[1];
4325
4325
  if (autocomplete === 'manual') {
4326
+ // In multiselect, the listbox manages its own active option via
4327
+ // keyboard navigation. When the last-selected value no longer
4328
+ // matches any option (e.g. after deselecting the only selected
4329
+ // option), preserve the existing active descendant so the next
4330
+ // Enter keypress can re-toggle the highlighted option.
4331
+ if (multiselect &&
4332
+ !element &&
4333
+ activeDescendant &&
4334
+ matchingOptions.has(activeDescendant.element)) {
4335
+ return;
4336
+ }
4326
4337
  setActiveDescendant(!element ? null : tslib.__assign({ element: element }, option));
4327
4338
  }
4328
4339
  else if (autocomplete === 'automatic' &&
@@ -5106,7 +5117,6 @@ function useMnemonics(_a) {
5106
5117
 
5107
5118
  var ActionList = React.forwardRef(function (_a, ref) {
5108
5119
  var _b = _a.selectionType, selectionType = _b === void 0 ? null : _b, onAction = _a.onAction, className = _a.className, children = _a.children, props = tslib.__rest(_a, ["selectionType", "onAction", "className", "children"]);
5109
- var actionListContext = useActionListContext();
5110
5120
  var activeElement = React.useRef();
5111
5121
  var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
5112
5122
  var handleActiveChange = React.useCallback(function (value) {
@@ -5128,12 +5138,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5128
5138
  ? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
5129
5139
  : '[role=option]'
5130
5140
  });
5131
- return (
5132
- // Note: we should be able to use listbox without passing a prop
5133
- // value for "multiselect"
5134
- // see: https://github.com/dequelabs/cauldron/issues/1890
5135
- // @ts-expect-error this should be allowed
5136
- React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5141
+ return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5137
5142
  if (ref) {
5138
5143
  setRef(ref, element);
5139
5144
  }
@@ -5142,7 +5147,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5142
5147
  /* Listbox comes with an explicit role of "listbox", but we want to either
5143
5148
  * use the role from props, or default to the intrinsic role */
5144
5149
  // eslint-disable-next-line jsx-a11y/aria-role
5145
- role: undefined, "aria-multiselectable": actionListContext.role === 'listbox' ? undefined : null, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5150
+ role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5146
5151
  React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
5147
5152
  });
5148
5153
  ActionList.displayName = 'ActionList';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "7.1.0-canary.d4fda8b7",
3
+ "version": "7.1.0-canary.df3401c2",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",