Bug 238093
| Summary: | preventScroll does not work with dynamically created elements | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Elliot Nahman <Elliot.nahman> |
| Component: | Forms | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | augus.dupin, caleb, cdumez, rik, simon.fraser, webkit-bug-importer, wenson_hsieh |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 15 | ||
| Hardware: | Mac (Intel) | ||
| OS: | macOS 11 | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=267051 | ||
Elliot Nahman
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Simon Fraser (smfr)
Thanks for the report. I can reproduce.
Radar WebKit Bug Importer
<rdar://problem/90502768>
Simon Fraser (smfr)
In the bad case we're scrolling via FrameSelection::updateAppearanceAfterLayoutOrStyleChange().
Simon Fraser (smfr)
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.