@lumx/react 4.17.1-alpha.0 → 4.17.1-alpha.1
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.
- package/index.d.ts +6 -2
- package/index.js +10 -4
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1862,10 +1862,14 @@ interface ComboboxEventMap {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
/** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
|
|
1864
1864
|
interface ComboboxCallbacks {
|
|
1865
|
-
/**
|
|
1865
|
+
/**
|
|
1866
|
+
* Called when an option is selected (click or keyboard).
|
|
1867
|
+
* Return `false` to skip the default behaviour of updating the input value via `onChange`.
|
|
1868
|
+
* The combobox will still close normally.
|
|
1869
|
+
*/
|
|
1866
1870
|
onSelect?(option: {
|
|
1867
1871
|
value: string;
|
|
1868
|
-
}): void;
|
|
1872
|
+
}): boolean | void;
|
|
1869
1873
|
}
|
|
1870
1874
|
/**
|
|
1871
1875
|
* Behavioral options for input-mode combobox (autocomplete/filter pattern).
|
package/index.js
CHANGED
|
@@ -7406,13 +7406,15 @@ function setupComboboxInput(input, options) {
|
|
|
7406
7406
|
/**
|
|
7407
7407
|
* Wraps the consumer's onSelect to perform input-mode side effects after selection:
|
|
7408
7408
|
* resets the filter and typing state.
|
|
7409
|
+
* Forwards the return value of the consumer callback.
|
|
7409
7410
|
*/
|
|
7410
7411
|
const onSelect = option => {
|
|
7411
|
-
optionOnSelect?.(option);
|
|
7412
|
+
const result = optionOnSelect?.(option);
|
|
7412
7413
|
userHasTyped = false;
|
|
7413
7414
|
if (autoFilter) {
|
|
7414
7415
|
handle.setFilter('');
|
|
7415
7416
|
}
|
|
7417
|
+
return result;
|
|
7416
7418
|
};
|
|
7417
7419
|
handle = setupCombobox({
|
|
7418
7420
|
onSelect
|
|
@@ -8176,9 +8178,13 @@ const ComboboxInput = forwardRef((props, ref) => {
|
|
|
8176
8178
|
if (!input) return undefined;
|
|
8177
8179
|
const handle = setupComboboxInput(input, {
|
|
8178
8180
|
onSelect(option) {
|
|
8179
|
-
//
|
|
8180
|
-
|
|
8181
|
-
|
|
8181
|
+
// Fire consumer callback first so it can return false before onChange.
|
|
8182
|
+
const prevented = onSelectRef.current?.(option) === false;
|
|
8183
|
+
// Update controlled value through React's normal onChange flow,
|
|
8184
|
+
// unless the consumer returned false.
|
|
8185
|
+
if (!prevented) {
|
|
8186
|
+
onChangeRef.current?.(option.value);
|
|
8187
|
+
}
|
|
8182
8188
|
},
|
|
8183
8189
|
onInput(value) {
|
|
8184
8190
|
// Keep controlled value in sync.
|