@sebgroup/green-core 3.32.0 → 3.32.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.
@@ -132,6 +132,7 @@ declare class Dropdown extends GdsFormControlElement implements OptionsContainer
132
132
  get navigableItems(): GdsOption[];
133
133
  private _elTriggerBtn;
134
134
  private _elSearchInput;
135
+ private _elListbox;
135
136
  connectedCallback(): void;
136
137
  disconnectedCallback(): void;
137
138
  render(): any;
@@ -5,7 +5,7 @@ import {
5
5
  __privateMethod,
6
6
  __privateSet
7
7
  } from "../../chunks/chunk.H2T4A5YY.js";
8
- var _optionElements, _Dropdown_instances, shouldShowFooter_fn, _renderCombobox, _renderTriggerButton, _handleBlur, _calcMaxHeight, _dispatchUISateEvent, _handlePopoverStateChange, _handleClearButton, _handleSearchFieldInput, _handleSearchFieldKeyDown, _handleListboxKeyDown, _handleOptionFocusChange, _handleOptionSelect, toggleOptionValue_fn, syncOptionSelection_fn, _focusListbox, _isPointerPressedInListbox, _handleListboxPointerDown, _handleListboxFocus, _isCommitting, commitSelection_fn, registerAutoCloseListener_fn, unregisterAutoCloseListener_fn, _blurCloseListener, _tabCloseListener;
8
+ var _optionElements, _Dropdown_instances, shouldShowFooter_fn, _renderCombobox, _renderTriggerButton, _handleBlur, _calcMaxHeight, _dispatchUISateEvent, _handlePopoverStateChange, _handleClearButton, _handleSearchFieldInput, _handleSearchFieldKeyDown, _handleListboxKeyDown, _handleOptionFocusChange, _handleOptionSelect, toggleOptionValue_fn, syncOptionSelection_fn, _focusListbox, _isPointerPressedInListbox, _handleListboxPointerDown, _handleListboxFocus, _isCommitting, commitSelection_fn, scrollOptionIntoView_fn, registerAutoCloseListener_fn, unregisterAutoCloseListener_fn, _blurCloseListener, _tabCloseListener;
9
9
  import { localized, msg, str } from "@lit/localize";
10
10
  import { nothing } from "lit";
11
11
  import { property, query } from "lit/decorators.js";
@@ -162,6 +162,8 @@ let Dropdown = class extends GdsFormControlElement {
162
162
  }
163
163
  if (__privateGet(this, _dispatchUISateEvent).call(this, e.detail.open, e.detail.reason)) {
164
164
  this.open = e.detail.open;
165
+ } else {
166
+ e.preventDefault();
165
167
  }
166
168
  });
167
169
  __privateAdd(this, _handleClearButton, (e) => {
@@ -535,9 +537,7 @@ let Dropdown = class extends GdsFormControlElement {
535
537
  const selectedOption = this.options.find((option) => option.selected);
536
538
  requestAnimationFrame(async () => {
537
539
  await this.updateComplete;
538
- selectedOption?.scrollIntoView({
539
- block: "center"
540
- });
540
+ __privateMethod(this, _Dropdown_instances, scrollOptionIntoView_fn).call(this, selectedOption);
541
541
  });
542
542
  }
543
543
  };
@@ -605,6 +605,22 @@ commitSelection_fn = function(value, options = {}) {
605
605
  __privateSet(this, _isCommitting, false);
606
606
  }
607
607
  };
608
+ /**
609
+ * Centers an option inside the listbox container by adjusting the container's own
610
+ * `scrollTop`. `Element.scrollIntoView` was used here previously, but it also scrolls
611
+ * ancestor scrollports, including the window when the popover is non-modal (combobox
612
+ * mode). That self-inflicted page scroll closes the popover through its own
613
+ * scroll-to-close behavior. See #3290.
614
+ */
615
+ scrollOptionIntoView_fn = function(option) {
616
+ const container = this._elListbox;
617
+ if (!container || !option) return;
618
+ const containerRect = container.getBoundingClientRect();
619
+ const optionRect = option.getBoundingClientRect();
620
+ const offsetFromContainerTop = optionRect.top - containerRect.top;
621
+ const centeredOffset = (containerRect.height - optionRect.height) / 2;
622
+ container.scrollTop += offsetFromContainerTop - centeredOffset;
623
+ };
608
624
  registerAutoCloseListener_fn = function() {
609
625
  this.addEventListener("blur", __privateGet(this, _blurCloseListener));
610
626
  this.addEventListener("gds-blur", __privateGet(this, _blurCloseListener));
@@ -678,6 +694,9 @@ __decorateClass([
678
694
  __decorateClass([
679
695
  query("#searchinput")
680
696
  ], Dropdown.prototype, "_elSearchInput", 2);
697
+ __decorateClass([
698
+ query("#listbox")
699
+ ], Dropdown.prototype, "_elListbox", 2);
681
700
  __decorateClass([
682
701
  observeLightDOM({
683
702
  attributes: true,