@skyscanner/backpack-web 42.13.1 → 42.13.3
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.
|
@@ -101,6 +101,18 @@ const BpkAutosuggest = /*#__PURE__*/forwardRef(({
|
|
|
101
101
|
changes,
|
|
102
102
|
type
|
|
103
103
|
} = actionAndChanges;
|
|
104
|
+
|
|
105
|
+
// Intercept InputBlur before the alwaysRenderSuggestions early-return
|
|
106
|
+
if (type === useCombobox.stateChangeTypes.InputBlur) {
|
|
107
|
+
const keepOpen = Boolean(alwaysRenderSuggestions && hasSuggestions);
|
|
108
|
+
return {
|
|
109
|
+
...changes,
|
|
110
|
+
isOpen: keepOpen,
|
|
111
|
+
highlightedIndex: -1,
|
|
112
|
+
selectedItem: state.selectedItem,
|
|
113
|
+
inputValue: state.inputValue
|
|
114
|
+
};
|
|
115
|
+
}
|
|
104
116
|
const shouldForceKeepOpen = alwaysRenderSuggestions && hasSuggestions && changes.isOpen === false;
|
|
105
117
|
if (shouldForceKeepOpen) {
|
|
106
118
|
return {
|
|
@@ -205,6 +217,11 @@ const BpkAutosuggest = /*#__PURE__*/forwardRef(({
|
|
|
205
217
|
onSuggestionHighlighted?.({
|
|
206
218
|
suggestion: currentSuggestion
|
|
207
219
|
});
|
|
220
|
+
|
|
221
|
+
// Only arm auto-select-on-blur for non-mouse-driven highlight changes.
|
|
222
|
+
if (type !== useCombobox.stateChangeTypes.ItemMouseMove && type !== useCombobox.stateChangeTypes.MenuMouseLeave) {
|
|
223
|
+
savedHighlightedIndexRef.current = newIndex ?? null;
|
|
224
|
+
}
|
|
208
225
|
const isArrowKey = type === useCombobox.stateChangeTypes.InputKeyDownArrowDown || type === useCombobox.stateChangeTypes.InputKeyDownArrowUp;
|
|
209
226
|
if (isArrowKey) {
|
|
210
227
|
if (currentSuggestion) {
|
|
@@ -272,8 +289,6 @@ const BpkAutosuggest = /*#__PURE__*/forwardRef(({
|
|
|
272
289
|
useEffect(() => {
|
|
273
290
|
if (highlightedIndex === previousHighlightedIndexRef.current) return;
|
|
274
291
|
previousHighlightedIndexRef.current = highlightedIndex;
|
|
275
|
-
// Save highlighted index to allow auto-selection on blur
|
|
276
|
-
savedHighlightedIndexRef.current = highlightedIndex;
|
|
277
292
|
const currentSuggestion = highlightedIndex != null && highlightedIndex >= 0 ? flattenedSuggestions?.[highlightedIndex] ?? null : null;
|
|
278
293
|
if (!currentSuggestion && originalInputOnPreviewRef.current !== null) {
|
|
279
294
|
if ((inputValue ?? '') !== originalInputOnPreviewRef.current) {
|
|
@@ -463,8 +478,11 @@ const BpkAutosuggest = /*#__PURE__*/forwardRef(({
|
|
|
463
478
|
highlightedSuggestion = firstSuggestion;
|
|
464
479
|
}
|
|
465
480
|
if (highlightedSuggestion) {
|
|
466
|
-
// Use setTimeout to ensure selectItem runs after the blur event completes
|
|
481
|
+
// Use setTimeout to ensure selectItem runs after the blur event completes.
|
|
467
482
|
setTimeout(() => {
|
|
483
|
+
if (committedSelectionRef.current) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
468
486
|
selectItem(highlightedSuggestion);
|
|
469
487
|
}, 0);
|
|
470
488
|
}
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-chatbot-input--cars{transition:border-color 200ms ease,box-shadow 200ms ease;border:.09375rem solid #c1c7cf;background:#fff;box-shadow:none;box-sizing:border-box;touch-action:manipulation;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-no-touch-support .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}:global(.bpk-no-touch-support) .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:active{border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:focus-within{box-shadow:0 0 0 .03125rem #0062e3;box-shadow:0 0 0 .03125rem var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227));border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--composer{position:relative;transition:transform .3s cubic-bezier(0.4, 0, 0.2, 1),box-shadow .3s cubic-bezier(0.4, 0, 0.2, 1);border:none;background:#fff;box-sizing:border-box;will-change:transform,box-shadow;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-chatbot-input--composer--with-shadow:focus-within{box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-chatbot-input--composer--overLimit{transform:translateY(-0.25rem)}
|
|
18
|
+
.bpk-chatbot-input--cars{transition:border-color 200ms ease,box-shadow 200ms ease;border:.09375rem solid #c1c7cf;background:#fff;box-shadow:none;box-sizing:border-box;touch-action:manipulation;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-no-touch-support .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}:global(.bpk-no-touch-support) .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:active{border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:focus-within{box-shadow:0 0 0 .03125rem #0062e3;box-shadow:0 0 0 .03125rem var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227));border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--composer{position:relative;transition:transform .3s cubic-bezier(0.4, 0, 0.2, 1),box-shadow .3s cubic-bezier(0.4, 0, 0.2, 1);border:none;background:#fff;box-sizing:border-box;will-change:transform,box-shadow;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-chatbot-input--composer--with-shadow{box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-chatbot-input--composer--with-shadow:focus-within{box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-chatbot-input--composer--overLimit{transform:translateY(-0.25rem)}
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-popover{transition:opacity 200ms ease-in-out;outline:0;background-color:#fff;opacity:1;border-radius:.5rem;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}@media(min-width: 32.0625rem){.bpk-popover{max-width:32rem;transition:opacity 50ms ease-in-out}}.bpk-popover--appear{opacity:0}.bpk-popover--appear-active{opacity:1}.bpk-popover__arrow{width:1.5rem;height:1.5rem;fill:#fff}.bpk-popover__arrow[data-hide]{visibility:hidden}.bpk-popover__body--padded{padding:1rem}.bpk-popover__body--padded:not(:last-of-type){padding-bottom:0}.bpk-popover__header{display:flex;padding:1rem 1rem 0;justify-content:space-between}.bpk-popover__header~.bpk-popover__body--padded{padding-top:.5rem}.bpk-popover__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-popover__footer{padding:.5rem 1rem;text-align:right}html[dir=rtl] .bpk-popover__footer{text-align:left}.bpk-popover__action{padding:0 1rem 1rem 1rem}
|
|
18
|
+
.bpk-popover{transition:opacity 200ms ease-in-out;outline:0;background-color:#fff;opacity:1;border-radius:.5rem;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}@media(min-width: 32.0625rem){.bpk-popover{max-width:32rem;transition:opacity 50ms ease-in-out}}.bpk-popover--container{outline:none}.bpk-popover--appear{opacity:0}.bpk-popover--appear-active{opacity:1}.bpk-popover__arrow{width:1.5rem;height:1.5rem;fill:#fff}.bpk-popover__arrow[data-hide]{visibility:hidden}.bpk-popover__body--padded{padding:1rem}.bpk-popover__body--padded:not(:last-of-type){padding-bottom:0}.bpk-popover__header{display:flex;padding:1rem 1rem 0;justify-content:space-between}.bpk-popover__header~.bpk-popover__body--padded{padding-top:.5rem}.bpk-popover__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-popover__footer{padding:.5rem 1rem;text-align:right}html[dir=rtl] .bpk-popover__footer{text-align:left}.bpk-popover__action{padding:0 1rem 1rem 1rem}
|