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

Open
#7,866 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
PHP
Stars
4.3k
Forks
1.1k
Avg merge
2d 9h
Merged PRs (30d)
52

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EasyCorp/EasyAdminBundle

All issues in EasyCorp/EasyAdminBundle

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.