@entur/dropdown 9.1.1 → 9.2.0

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/dist/dropdown.cjs CHANGED
@@ -253,7 +253,8 @@ const DropdownFieldAppendix = React.forwardRef(
253
253
  button.IconButton,
254
254
  {
255
255
  className: classNames("eds-dropdown__appendix__toggle-button", {
256
- "eds-dropdown__appendix__toggle-button--open": isOpen
256
+ "eds-dropdown__appendix__toggle-button--open": isOpen,
257
+ "eds-dropdown__appendix__toggle-button--loading": loading
257
258
  }),
258
259
  ref,
259
260
  "aria-label": getToggleAriaLabel(),
@@ -692,11 +693,18 @@ const SearchableDropdown = React.forwardRef(
692
693
  const { refs, floatingStyles, update } = reactDom.useFloating({
693
694
  open: isOpen,
694
695
  placement: "bottom-start",
696
+ // Fixed takes the menu out of the field's scroll container, so shift()'s
697
+ // padding cannot become horizontal overflow there
698
+ strategy: "fixed",
695
699
  middleware: [
696
700
  reactDom.offset(tokens.space.extraSmall2),
697
701
  reactDom.shift({ padding: tokens.space.extraSmall }),
698
702
  reactDom.size({
699
- apply({ elements, availableHeight }) {
703
+ apply({ elements, rects, availableHeight }) {
704
+ elements.floating.style.setProperty(
705
+ "--list-width",
706
+ `${rects.reference.width}px`
707
+ );
700
708
  elements.floating.style.setProperty(
701
709
  "--list-max-height",
702
710
  `${clamp(10 * 16, availableHeight, 20 * 16)}px`
@@ -1074,11 +1082,18 @@ const MultiSelect = React.forwardRef(
1074
1082
  const { refs, floatingStyles, update } = reactDom.useFloating({
1075
1083
  open: isOpen,
1076
1084
  placement: "bottom-start",
1085
+ // Fixed takes the menu out of the field's scroll container, so shift()'s
1086
+ // padding cannot become horizontal overflow there
1087
+ strategy: "fixed",
1077
1088
  middleware: [
1078
1089
  reactDom.offset(tokens.space.extraSmall2),
1079
1090
  reactDom.shift({ padding: tokens.space.extraSmall }),
1080
1091
  reactDom.size({
1081
- apply({ elements, availableHeight }) {
1092
+ apply({ elements, rects, availableHeight }) {
1093
+ elements.floating.style.setProperty(
1094
+ "--list-width",
1095
+ `${rects.reference.width}px`
1096
+ );
1082
1097
  elements.floating.style.setProperty(
1083
1098
  "--list-max-height",
1084
1099
  `${clamp(10 * 16, availableHeight, 20 * 16)}px`
@@ -1325,11 +1340,18 @@ const Dropdown = React.forwardRef(
1325
1340
  const { refs, floatingStyles, update } = reactDom.useFloating({
1326
1341
  open: isOpen,
1327
1342
  placement: "bottom-start",
1343
+ // Fixed takes the menu out of the field's scroll container, so shift()'s
1344
+ // padding cannot become horizontal overflow there
1345
+ strategy: "fixed",
1328
1346
  middleware: [
1329
1347
  reactDom.offset(tokens.space.extraSmall2),
1330
1348
  reactDom.shift({ padding: tokens.space.extraSmall }),
1331
1349
  reactDom.size({
1332
- apply({ elements, availableHeight }) {
1350
+ apply({ elements, rects, availableHeight }) {
1351
+ elements.floating.style.setProperty(
1352
+ "--list-width",
1353
+ `${rects.reference.width}px`
1354
+ );
1333
1355
  elements.floating.style.setProperty(
1334
1356
  "--list-max-height",
1335
1357
  `${clamp(10 * 16, availableHeight, 20 * 16)}px`