Skip to content

Selection of several elements causing jump to the top of the Theme Editor #37893

Closed

Description

@oglekler

Description

In Theme Editor selection of several elements causing a jump to the top of the Editor

Step-by-step reproduction instructions

  1. Go to еру Theme Editor
  2. Scroll down the Editor to edit something further below
  3. Add several paragraphs/items
  4. Try to select them

unexpected-jump-1

unexpected-jump

I didn't manage to get such behaviour while editing a post in the Block Editor.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. annezazu commented on Jan 11, 2022

    @annezazu
    Contributor

    I can replicate this with 5.9 RC2 using TT2. Adding to the 5.9 for triage but not quite sure this is high priority enough to address.

  2. added
    [Type] Bug
    General Interface
    on Jan 11, 2022
  3. carolinan commented on Jan 12, 2022

    @carolinan
    Contributor

    I can reproduce this also with different themes (5.9 RC2 with Gutenberg trunk)

  4. added
    [Feature] Site Editor
    on Jan 12, 2022
  5. youknowriad commented on Jan 17, 2022

    @youknowriad
    Contributor

    mmm! I haven't been able to reproduce personally. Could have this been recently fixed somehow?

  6. youknowriad commented on Jan 17, 2022

    @youknowriad
    Contributor

    Ok I reproduce sometimes but not consistently. I think I reproduce if I drag my mouse to the bottom of the screen but otherwise I don't.

  7. youknowriad commented on Jan 17, 2022

    @youknowriad
    Contributor

    So I tried to debug this more and found that this is related to the line here

    // For some browsers, like Safari, it is important that focus happens
    // BEFORE selection.
    node.focus();

    Basically if we remove that line, everything seems to work properly.

    The problem though is that the origin of this line is this PR #30202 (it was refactored later as hooks but that's where it comes from originally) and on my testing if I remove the line, copy/pasting multi-selection in Safari breaks, it results in a lot of extra empty lines in RichTexts.

    Also if I try to guess, the issue is only visible in the site editor because the post editor is not Iframed yet and "focusing the canvas" is scrolling the page only if the browser selection actually contains something that is outside the editor canvas, for instance in my testing above, if I move the mouse over the footer (breadcrumb) of the editor.

    Ideally we should find a fix that solves both issues at the same time. Potentially remove any "ranges" that are outside the "node" from the selection object before calling node.focus but not sure if that works. cc @mcsf

  8. added
    [Feature] Writing Flow
    on Aug 17, 2023
  9. ntsekouras commented on Sep 21, 2026

    @ntsekouras
    Contributor

    I think this was fixed in #80651, which made the canvas focus during multi-selection use preventScroll so the editor doesn't scroll back to the top anymore. This doesn't seem reproducible on trunk (tested with Chrome and Safari), so I'm closing this one. Feel free to reopen if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    General Interface[Feature] Site Editor[Feature] Writing Flow[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions