Autocomplete: dropdown never flips above the field (opens below the viewport) and is clipped by the fieldset "overflow: clip"

Aperta
#7,866 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, php, symfony

Direzione di ricerca

Start with assets/js/autocomplete.js and the theme CSS for .form-fieldset-body; the issue identifies both as sources of the dropdown placement and clipping behavior. Review the autocomplete setup and existing fieldset overflow rules, then reproduce the reported behavior in a short viewport and with the clipping mitigation disabled. Done means the dropdown remains visible near the viewport edge and is not clipped inside fieldsets; the payload does not name a test file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

design
Describe the bug

A ChoiceField / autocomplete placed as the last field of a fieldset opens its TomSelect list downwards — and nothing flips or clamps it, so when the field sits near the lower edge of the window the list opens (almost) entirely below the viewport: the user clicks the select and sees an empty/near-empty dropdown.

The bundled TomSelect has no placement logic at all: positionDropdown() returns immediately unless dropdownParent === 'body', and even then it positions the list strictly below the control (top = control.offsetHeight + rect.top + window.scrollY). There is no flip/clamp in 2.4.1 (the version pinned in yarn.lock) and none in upstream master (2.6.2). When the wrapper is not body, the position comes from the theme CSS (inset-block-start: 100%), i.e. always below. EA never sets dropdownParent when creating the widget (assets/js/autocomplete.js — grep dropdownParent finds nothing from 5.2.0 to 5.7.0).

Measured on a settings CRUD form (EA 5.6.1, Symfony 7.x, PHP 8.x), 249 px tall list, control at y = 257:

viewport height list position really visible in the viewport
700 px 290–539 px 246 px
540 px 290–539 px 246 px
480 px 290–539 px 186 px
400 px 290–539 px 108 px
≤ 290 px 290–539 px 0 px (the document does grow, so a manual scroll reaches it — but the list is not visible when it opens)

So the smaller the window (or the lower the field after scrolling), the worse it gets; in a short window the dropdown looks like it "does not open".

Second, related problem: the list is rendered inside the clipped fieldset body

TomSelect appends .ts-dropdown inside the field wrapper (.ts-wrapper), i.e. inside .form-fieldset-body, which has overflow: clip for the collapse animation. EA mitigates that with:

.form-fieldset-body.show:not(.collapsing) {
    overflow-inline: clip;
    overflow-block: visible;
}

That mitigation depends on the overflow-inline / overflow-block logical longhands, and only covers .show:not(.collapsing). Where the longhands do not apply (Chrome < 135, Safari < 26, WebView — see also #7235 and #7050, where these logical overflow properties caused autocomplete problems on Safari and mobile Chrome) or while a body is collapsed/animating, the physical overflow: clip wins and only ~18 px of the list are painted — the dropdown looks invisible even in a tall window.

Reproduction of that half (any browser — just drop the mitigation in DevTools):

.form-fieldset-body.show:not(.collapsing) { overflow: clip !important; }
.form-fieldset-body.show:not(.collapsing) > .row { overflow: clip !important; }

Measured with document.elementFromPoint() probes at 1280×700 (Chrome 155 and Firefox 158): the fieldset body box is 144–311 px, .ts-dropdown is 290–539 px; painted dropdown goes from 18 px (290–308) to 240 px (292–532) as soon as the mitigation applies.

Suggested fix
  1. Placement (the reported symptom): position the list against the viewport — flip above the control or clamp its height/max-height when there is not enough room below. TomSelect upstream has no such logic, so it has to live in assets/js/autocomplete.js / the EA theme.
  2. Clipping: set dropdownParent: 'body' when creating the widget in assets/js/autocomplete.js — the list then leaves the clipped box (verified here: parentElement of .ts-dropdown becomes <body>, no clipping ancestor remains, and TomSelect keeps re-anchoring it to the control on window scroll/resize). Alternatively apply overflow: clip only while a fieldset is actually collapsing (.form-fieldset-body.collapsing, .collapse:not(.show)) instead of on every body, or clip with clip-path only during the animation and drop it afterwards.
Workaround for users (documented hook)
document.addEventListener('ea.autocomplete.pre-connect', (event) => {
    event.detail.config.dropdownParent = 'body';
});
Environment
  • EasyAdminBundle 5.6.1 (the clipping CSS is present in 5.2.0 … 5.7.0)
  • TomSelect 2.4.1 (yarn.lock); upstream 2.6.2 has the same positionDropdown()
  • Symfony 7.x, PHP 8.x
  • Reported by a user on Firefox 157 (Linux, 1920×1000 window; the field ends up near the lower window edge): "when the dropdown is at the bottom, you can't see it when it opens". Verified with Chrome 155 and Firefox 158.
Lingua principale
PHP
Stelle
4.3k
Fork
1.1k
Merge medio
2g 9h
PR unite (30g)
52

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di EasyCorp/EasyAdminBundle

Tutte le issue di EasyCorp/EasyAdminBundle

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.