@klippa/ngx-enhancy-forms 14.1.2 → 14.1.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.
@@ -836,12 +836,24 @@ class SelectComponent extends ValueAccessorBase {
836
836
  }
837
837
  setWidthBasedOnOptionsWidths() {
838
838
  if (this.truncateOptions === false) {
839
- const widths = Array.from(this.elRef.nativeElement.querySelectorAll('.ng-option div')).map((e) => e.scrollWidth);
840
- const maxWidth = Math.max(...widths);
841
- const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
842
- if (dropdownPanel) {
843
- dropdownPanel.style.width = `${maxWidth + 40}px`;
844
- }
839
+ setTimeout(() => {
840
+ const widths = Array.from(this.elRef.nativeElement.querySelectorAll('.ng-option div')).map((e) => e.scrollWidth);
841
+ const maxWidth = Math.max(...widths);
842
+ const dropdownPanel = this.elRef.nativeElement.querySelector('ng-dropdown-panel');
843
+ if (dropdownPanel) {
844
+ dropdownPanel.style.width = `${maxWidth + 40}px`;
845
+ }
846
+ let current = this.elRef.nativeElement;
847
+ while (current.parentElement && !this.isLimitingContainer(current)) {
848
+ current = current.parentElement;
849
+ }
850
+ if (dropdownPanel) {
851
+ const overflow = dropdownPanel.getBoundingClientRect().left + maxWidth + 40 - current.clientWidth;
852
+ if (overflow > 0) {
853
+ dropdownPanel.style.left = `-${overflow}px`;
854
+ }
855
+ }
856
+ });
845
857
  }
846
858
  }
847
859
  determineDropdownPosition() {