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
Thanks for the report. I can reproduce.
<rdar://problem/90502768>
In the bad case we're scrolling via FrameSelection::updateAppearanceAfterLayoutOrStyleChange().
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.