Skip to content

Commit

Permalink
chore: merge develop (#344)
Browse files Browse the repository at this point in the history
Co-authored-by: Ante Novokmet <[email protected]>
Co-authored-by: Omar Elhawary <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent 95fec3b commit 0d97a8c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/docs/src/routes/docs/core/components/combobox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ We expose a CSS custom property `--kb-combobox-content-transform-origin` which c
| removeOnBackspace | `boolean` <br/> When `multiple` is true, whether the last selected option should be removed when the user press the Backspace key and the input is empty. |
| allowDuplicateSelectionEvents | `boolean` <br/> Whether `onChange` should fire even if the new value is the same as the last. |
| disallowEmptySelection | `boolean` <br/> Whether the combobox allows empty selection or not. |
| closeOnSelection | `boolean` <br/> Whether the combobox closes after selection. |
| selectionBehavior | `'toggle' \| 'replace'` <br/> How selection should behave in the combobox. |
| virtualized | `boolean` <br/> Whether the combobox uses virtual scrolling. |
| modal | `boolean` <br/> Whether the combobox should be the only visible content for screen readers, when set to `true`: <br/> - interaction with outside elements will be disabled. <br/> - scroll will be locked. <br/> - focus will be locked inside the combobox content. <br/> - elements outside the combobox content will not be visible for screen readers. |
Expand Down
1 change: 1 addition & 0 deletions apps/docs/src/routes/docs/core/components/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ We expose a CSS custom property `--kb-select-content-transform-origin` which can
| onOpenChange | `(open: boolean) => void` <br/> Event handler called when the open state of the select changes. |
| allowDuplicateSelectionEvents | `boolean` <br/> Whether `onChange` should fire even if the new value is the same as the last. |
| disallowEmptySelection | `boolean` <br/> Whether the select allows empty selection or not. |
| closeOnSelection | `boolean` <br/> Whether the select closes after selection. |
| selectionBehavior | `'toggle' \| 'replace'` <br/> How selection should behave in the select. |
| virtualized | `boolean` <br/> Whether the select uses virtual scrolling. |
| modal | `boolean` <br/> Whether the select should be the only visible content for screen readers, when set to `true`: <br/> - interaction with outside elements will be disabled. <br/> - scroll will be locked. <br/> - focus will be locked inside the select content. <br/> - elements outside the select content will not be visible for screen readers. |
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/combobox/combobox-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export interface ComboboxBaseOptions<Option, OptGroup = never>
/** Whether the combobox allows empty selection. */
disallowEmptySelection?: boolean;

/** Whether the combobox closes after selection. */
closeOnSelection?: boolean;

/**
* When `selectionMode` is "multiple".
* Whether the last selected option should be removed when the user press the Backspace key and the input is empty.
Expand Down Expand Up @@ -266,6 +269,7 @@ export function ComboboxBase<Option, OptGroup = never>(
allowsEmptyCollection: false,
disallowEmptySelection: false,
allowDuplicateSelectionEvents: true,
closeOnSelection: props.selectionMode === "single",
removeOnBackspace: true,
gutter: 8,
sameWidth: true,
Expand Down Expand Up @@ -304,6 +308,7 @@ export function ComboboxBase<Option, OptGroup = never>(
"defaultFilter",
"shouldFocusWrap",
"allowsEmptyCollection",
"closeOnSelection",
"removeOnBackspace",
"selectionBehavior",
"selectionMode",
Expand Down Expand Up @@ -511,7 +516,7 @@ export function ComboboxBase<Option, OptGroup = never>(
onSelectionChange: (selectedKeys) => {
local.onChange?.(getOptionsFromValues(selectedKeys));

if (local.selectionMode === "single") {
if (local.closeOnSelection) {
// Only close if an option is selected.
// Prevents the combobox to close and reopen when the input is cleared.
if (disclosureState.isOpen() && selectedKeys.size > 0) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/combobox/combobox-listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function ComboboxListbox<Option = any, OptGroup = never>(
aria-labelledby={ariaLabelledBy()}
renderItem={context.renderItem}
renderSection={context.renderSection}
virtualized={context.isVirtualized()}
{...others}
/>
);
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/select/select-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export interface SelectBaseOptions<Option, OptGroup = never>
/** Whether the select allows empty selection. */
disallowEmptySelection?: boolean;

/** Whether the select closes after selection. */
closeOnSelection?: boolean;

/** Whether typeahead is disabled. */
disallowTypeAhead?: boolean;

Expand Down Expand Up @@ -219,6 +222,7 @@ export function SelectBase<Option, OptGroup = never>(
id: defaultId,
selectionMode: "single",
disallowEmptySelection: false,
closeOnSelection: props.selectionMode === "single",
allowDuplicateSelectionEvents: true,
gutter: 8,
sameWidth: true,
Expand Down Expand Up @@ -247,6 +251,7 @@ export function SelectBase<Option, OptGroup = never>(
"keyboardDelegate",
"allowDuplicateSelectionEvents",
"disallowEmptySelection",
"closeOnSelection",
"disallowTypeAhead",
"shouldFocusWrap",
"selectionBehavior",
Expand Down Expand Up @@ -356,7 +361,7 @@ export function SelectBase<Option, OptGroup = never>(
onSelectionChange: (selectedKeys) => {
local.onChange?.(getOptionsFromValues(selectedKeys));

if (local.selectionMode === "single") {
if (local.closeOnSelection) {
close();
}
},
Expand Down

0 comments on commit 0d97a8c

Please sign in to comment.