Problem/Motivation
While investigating #3631339: [random test failure] FieldTest::testModalDialogTitle fails intermittently, I found that Drupal dialogs first open at the wrong position, which is then corrected about 20ms later:
![]() |
![]() |
This fitted surprisingly well with a subconscious aversion to Drupal dialogs that I'd had for some time. Like an unexplainable, involuntary, autonomic reaction, something just felt off.
Now I can explain it, managed to capture the quite perceptible jump in a video, and we may now fix its cause.
While not reaching the three flashes threshold of WCAG 2.3.1/2.3.2, the abrupt repositioning is still distracting and may cause averse reactions in other users as well. Unnecessarily abrupt visual motion may even contribute to dizziness, nausea or headaches in motion-sensitive users, as described in Understanding SC 2.3.3.
Steps to reproduce
While not necessarily restricted to Views, to reproduce the issue please:
- Edit some view in Views UI.
- Scroll down and open some dialog.
- Notice (or film in slow-motion) the dialog first appearing too far down, then jumping upwards.
Proposed resolution
To remove the delayed initial resize, we need to calculate the dialog's size and position correctly before opening the dialog. Getting there however requires a few related bugfixes:
- Normalize numeric strings with or without "px" to numbers, and convert percentage heights to pixels.
- Normalize
autoResizeto a boolean afterbeforecreatelisteners had a chance to modify it. - Set
position: fixedfor dialogs withautoResizeenabled before jQuery UI calculates the initial coordinates. - Preserve positioning options that keep non-modal dialogs within the viewport.
- Retain
autoResizeupdate on viewport and displacement changes using the shared calculation methods.
To avoid regressions, expand our quite a bit lacking test coverage for dialog sizes and positions, including modal and non-modal dialogs, reopening, and option changes.
Remaining tasks
Accessibility and Javascript review.
User interface changes
None, besides dialogs opening at their correct position immediately:

Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Dialogs no longer jump into position after opening.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3633792
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:


Comments
Comment #3
panchoReady for review. This should also resolve #3631339: [random test failure] FieldTest::testModalDialogTitle fails intermittently.
The underlying problems in unpatched Core are:
In unpatched Core, jQuery UI first positions the dialog with
position: absolute.It's only after the dialog has already opened that Drupal's
autoResizecode changes it toposition: fixed, however without recalculating its coordinates. On a scrolled page, this can put the dialog too far down, potentially leaving its title outside the viewport. A delayed correction then makes the dialog jump into position.The delayed resizing corrects the position by triggering
_position(), but only after the dialog has already opened. This makes the dialog jump into position, for both modal and non-modal dialogs.With a numeric
maxHeight, the delayed resize does not perform the percentage conversion nor the appropriate position correction.Additional problem is: after the AJAX round trip, the height value reaches our JS as the string
"400"and is passed as such to jQuery UI, which explicitly checks itstypeofand then discards the value rather than silently converting it into400.And as
resetPosition()replaces the position options without preservingcollision: 'fit', the top of an oversized non-modal dialog can move outside the viewport. Views UI normally uses95%, but numeric sizes are relevant for other callers.For modal dialogs, there is another consequence:
bodyScrollLock.lock()setsoverflow: hiddenon the root element. The misplaced title can then be clipped outside the viewport, so ChromeDriver treats it as hidden.getText()may return an empty string, whilewaitForElementVisible()may time out.This may explain the intermittent failures in #3631339: [random test failure] FieldTest::testModalDialogTitle fails intermittently, when the test checks the title before the delayed correction happens. The timing differences between sometimes failing CI runs and mostly passing local test runs are not yet fully understood.
This MR converts the requested sizes and sets fixed positioning before jQuery UI calculates the initial coordinates, preserving collision handling. Dialogs now open at their intended size and position, without needing the delayed initial correction.
autoResizeupdates when the viewport or Drupal displacement offsets change remain supported.Comment #4
smustgrave commentedWas this written with AI by chance?
Comment #5
panchoStephen,
yes, as I already explained when you last asked me, I do use AI for assistance. But no, it's not written by AI. I do take responsibility for every single word I chose and every deficit I overlooked.
Coming from the flaky tests issue, I have, however, put hours over hours – including a whole sleepless night – into thoroughly investigating this problem, analyzing ChromeDriver's behaviour, confirming and documenting the UI bug in practice, developing a quick fix, expanding it into a proper, thorough solution, making sure all relevant scenarios are properly taken care of, and expanding the test coverage.
Being confronted with yet another gotcha question about AI, without any concrete concern about the contribution itself, is disheartening. I may be on the more verbose side, but I think the level of detail is warranted by the complexity of this issue. Whenever my issue summaries for rather obvious tasks or fixes are on the shorter side, such as in:
you're not ok with it either.
I've tried to take it in good humour, but that's getting increasingly difficult.
If there's something wrong with my explanation, design decisions, technical scope, implementation or test coverage, I'm very happy to discuss it. That's the feedback I'm hoping for and that I would find most helpful. Just tell me what's wrong and I'll fix it and learn from the constructive criticism.
But you'll understand that I value my time, my work and particularly my dignity too much to just keep playing gotcha games. I'd rather take some time off.
Comment #6
smustgrave commentedPer the policy please disclose per ticket
Comment #7
smustgrave commentedHit submit before I finished
But disclosing is needed for those tickets.
It’s not meant to discourage and it’s good you review the submissions but it’s for the reviewers and committers who need to now look at it.
Comment #8
xjm@pancho, apologies for it feeling like a "gotcha" question. It's really not meant to be. It's just part of our contribution policy to document it, to help reviewers, ensure transparency, and be able to reference in the future. So please do document it each time when you are drafting code or text with the help of AI; this can really be something simple like:
Or:
Or whatnot.
Also please note that verbosity in general is a real difficulty, not just something folks are using to fingerprint your contributions. More words is more words for the maintainer to read and process. I recommend editing more by hand to reduce words in comments you draft, and adding skills to your LLM to make it write less verbose prose if such is available.
Comment #9
xjmOh, and please do use the template header section when creating new issues also. Thanks!
Comment #10
smustgrave commentedAnd I do apologize if that’s how I came off. I review so many issues sometimes quick. So note to slow down to myself to not come off like that.
Comment #11
pancho<3
Comment #12
mherchelCouple notes on this:
<dialog>element in #2158943: Add a native dialog element using HTMX to deprecate the jQuery UI dialog. Just FYI