Remove the unnecessary fixed class (absolute should work fine)

This commit is contained in:
Sebastian Zoglowek 2025-08-25 19:44:27 +02:00
commit e2ca9e2426
4 changed files with 6 additions and 13 deletions

View file

@ -160,7 +160,7 @@ class Choices {
_dropdownParent: HTMLElement | null;
_dropdownFixed: boolean;
_dropdownDetached: boolean;
constructor(
element: string | Element | HTMLInputElement | HTMLSelectElement = '[data-choice]',
@ -323,14 +323,14 @@ class Choices {
return;
}
// Position fixed for dropdown items
this._dropdownFixed = false;
// Dropdown is detached from the original wrapper
this._dropdownDetached = false;
if (config.dropdownParent) {
const parent = this._docRoot.querySelector<HTMLElement>(config.dropdownParent);
if (parent) {
this._dropdownFixed = true;
this._dropdownDetached = true;
this._dropdownParent = parent;
}
}
@ -530,7 +530,7 @@ class Choices {
requestAnimationFrame(() => {
this.dropdown.show();
if (this._dropdownFixed) {
if (this._dropdownDetached) {
const containerRect = this.containerOuter.element.getBoundingClientRect();
this.dropdown.element.style.top = `${containerRect.bottom}px`;
this.dropdown.element.style.left = `${containerRect.left}px`;
@ -2298,7 +2298,7 @@ class Choices {
this.input.setWidth();
}
if (this._dropdownFixed && this._dropdownParent instanceof HTMLElement) {
if (this._dropdownDetached && this._dropdownParent instanceof HTMLElement) {
const { fixed } = this.config.classNames;
dropdownParent = this._dropdownParent;
addClassesToElement(dropdownElement, fixed);

View file

@ -18,7 +18,6 @@ export const DEFAULT_CLASSNAMES: ClassNames = {
itemChoice: ['choices__item--choice'],
description: ['choices__description'],
placeholder: ['choices__placeholder'],
fixed: ['choices__position--fixed'],
group: ['choices__group'],
groupHeading: ['choices__heading'],
button: ['choices__button'],

View file

@ -28,8 +28,6 @@ export interface ClassNames {
description: string | Array<string>;
/** @default ['choices__placeholder'] */
placeholder: string | Array<string>;
/** @default ['choices__position-fixed'] */
fixed: string | Array<string>;
/** @default ['choices__group'] */
group: string | Array<string>;
/** @default ['choices__heading'] */

View file

@ -272,10 +272,6 @@ $choices-placeholder-opacity: 0.5 !default;
}
}
.#{$choices-selector}__position--fixed {
position: fixed !important;
}
%choices-dropdown {
display: none;
z-index: var(--choices-z-index, #{$choices-z-index});