@entur/dropdown 6.0.11 → 6.0.12

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.
@@ -1810,15 +1810,23 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
1810
1810
  inputValue = _useCombobox.inputValue,
1811
1811
  setInputValue = _useCombobox.setInputValue;
1812
1812
  var _useFloating = reactDom.useFloating({
1813
- whileElementsMounted: function whileElementsMounted(ref, _float, update) {
1814
- return reactDom.autoUpdate(ref, _float, update);
1815
- },
1816
1813
  placement: 'bottom-start',
1817
1814
  open: isOpen,
1818
1815
  middleware: [reactDom.offset(tokens.space.extraSmall2), reactDom.flip()]
1819
1816
  }),
1820
1817
  refs = _useFloating.refs,
1821
- floatingStyles = _useFloating.floatingStyles;
1818
+ floatingStyles = _useFloating.floatingStyles,
1819
+ elements = _useFloating.elements,
1820
+ update = _useFloating.update;
1821
+ // Since we use CSS instead of conditional rendering when hiding dropdownlist
1822
+ // we can't use the whileElementsMounted option and need to handle
1823
+ // cleanup ourselves. See https://floating-ui.com/docs/autoupdate
1824
+ React.useEffect(function () {
1825
+ if (isOpen && elements.reference && elements.floating) {
1826
+ var cleanup = reactDom.autoUpdate(elements.reference, elements.floating, update);
1827
+ return cleanup;
1828
+ }
1829
+ }, [isOpen, elements, update]);
1822
1830
  var handleOnClear = function handleOnClear() {
1823
1831
  var _inputRef$current;
1824
1832
  onChange(null);
@@ -2162,15 +2170,23 @@ var MultiSelect = function MultiSelect(_ref) {
2162
2170
  openMenu = _useCombobox.openMenu,
2163
2171
  setInputValue = _useCombobox.setInputValue;
2164
2172
  var _useFloating = reactDom.useFloating({
2165
- whileElementsMounted: function whileElementsMounted(ref, _float, update) {
2166
- return reactDom.autoUpdate(ref, _float, update);
2167
- },
2168
2173
  placement: 'bottom-start',
2169
2174
  open: isOpen,
2170
2175
  middleware: [reactDom.offset(tokens.space.extraSmall2), reactDom.flip()]
2171
2176
  }),
2172
2177
  refs = _useFloating.refs,
2173
- floatingStyles = _useFloating.floatingStyles;
2178
+ floatingStyles = _useFloating.floatingStyles,
2179
+ elements = _useFloating.elements,
2180
+ update = _useFloating.update;
2181
+ // Since we use CSS instead of conditional rendering when hiding dropdownlist
2182
+ // we can't use the whileElementsMounted option and need to handle
2183
+ // cleanup ourselves. See https://floating-ui.com/docs/autoupdate
2184
+ React.useEffect(function () {
2185
+ if (isOpen && elements.reference && elements.floating) {
2186
+ var cleanup = reactDom.autoUpdate(elements.reference, elements.floating, update);
2187
+ return cleanup;
2188
+ }
2189
+ }, [isOpen, elements, update]);
2174
2190
  var handleOnClear = function handleOnClear() {
2175
2191
  var _inputRef$current3;
2176
2192
  onChange([]);
@@ -2366,15 +2382,23 @@ var Dropdown = function Dropdown(_ref) {
2366
2382
  getToggleButtonProps = _useSelect.getToggleButtonProps,
2367
2383
  highlightedIndex = _useSelect.highlightedIndex;
2368
2384
  var _useFloating = reactDom.useFloating({
2369
- whileElementsMounted: function whileElementsMounted(ref, _float, update) {
2370
- return reactDom.autoUpdate(ref, _float, update);
2371
- },
2372
2385
  placement: 'bottom-start',
2373
2386
  open: isOpen,
2374
2387
  middleware: [reactDom.offset(tokens.space.extraSmall2), reactDom.flip()]
2375
2388
  }),
2376
2389
  refs = _useFloating.refs,
2377
- floatingStyles = _useFloating.floatingStyles;
2390
+ floatingStyles = _useFloating.floatingStyles,
2391
+ elements = _useFloating.elements,
2392
+ update = _useFloating.update;
2393
+ // Since we use CSS instead of conditional rendering when hiding dropdownlist
2394
+ // we can't use the whileElementsMounted option and need to handle
2395
+ // cleanup ourselves. See https://floating-ui.com/docs/autoupdate
2396
+ React.useEffect(function () {
2397
+ if (isOpen && elements.reference && elements.floating) {
2398
+ var cleanup = reactDom.autoUpdate(elements.reference, elements.floating, update);
2399
+ return cleanup;
2400
+ }
2401
+ }, [isOpen, elements, update]);
2378
2402
  return React.createElement(form.BaseFormControl, _extends({
2379
2403
  append: React.createElement(FieldAppend$1, {
2380
2404
  ariaHiddenToggleButton: true,