NEW 238093
preventScroll does not work with dynamically created elements
https://bugs.webkit.org/show_bug.cgi?id=238093
Summary preventScroll does not work with dynamically created elements
Elliot Nahman
Reported 2022-03-18 13:46:22 PDT
Safari 15 appears to have implemented the preventScroll option for Element.focus(). See the resolved webkit bug: https://bugs.webkit.org/show_bug.cgi?id=178583. While this feature works fine for elements already existing in the DOM, it does not work for dynamically added elements. Please see: https://codepen.io/nonmetalhail/pen/KKZzagd
Attachments
Simon Fraser (smfr)
Comment 1 2022-03-18 13:52:27 PDT
Thanks for the report. I can reproduce.
Radar WebKit Bug Importer
Comment 2 2022-03-18 13:52:39 PDT
Simon Fraser (smfr)
Comment 3 2022-03-18 14:12:36 PDT
In the bad case we're scrolling via FrameSelection::updateAppearanceAfterLayoutOrStyleChange().
Simon Fraser (smfr)
Comment 4 2022-03-18 14:17:42 PDT
Layout calls FrameSelection::setNeedsSelectionUpdate() which resets m_selectionRevealMode to SelectionRevealMode::Reveal here: if (innerTextSizeChanged && frame().selection().isFocusedAndActive() && document().focusedElement() == &inputElement()) { // The caps lock indicator was hidden or shown. If it is now visible then it may be occluding // the current selection (say, the caret was after the last character in the text field). // Schedule an update and reveal of the current selection. frame().selection().setNeedsSelectionUpdate(FrameSelection::RevealSelectionAfterUpdate::Forced); } This is trying to ensure that text within the input is scrolled into view, but has the side effect of also triggering page scrolling.
Note You need to log in before you can comment on or make changes to this bug.