Skip to content

Bug: HorizontalRule lexical playground #7758

Open

Description

@username14415

I'm not sure whether this is a bug, but shouldn't the horizontal rule prevent the cursor from being placed at its start?

tested on the playground

Screen.Recording.2025-08-14.at.03.17.28.mov

Activity

  1. harshmetkel24 commented on Aug 24, 2025

    @harshmetkel24
    Contributor

    https://github.com/user-attachments/assets/2ce470e6-6216-4efc-9a59-2dbbc96d78c0
    Even Google Docs seems to allow that. Someone from the Lexical team could confirm this behavior as wel

  2. username14415 commented on Aug 28, 2025

    @username14415
    Author

    IMO Google does it better, it allows setting both start and end, and also checks the cursor position.
    In Lexical, the start position is below the element, while in Google it's on the left.

  3. niikkhilsharma commented on Sep 30, 2025

    @niikkhilsharma
    Contributor

    This is literally an issue where clicking above the horizontal rule brings your cursor down, and when you type, it shows the text above the horizontal rule.

    @etrepum
    Can you please verify it that's an issue

  4. etrepum commented on Oct 1, 2025

    @etrepum
    Collaborator

    I think the expected behavior here would be to have clicks be handled in the basically same way that the arrow keys are, where it will switch to a NodeSelection of the HorizontalRuleNode instead of a specific position before or after the node.

  5. etrepum commented on Oct 1, 2025

    @etrepum
    Collaborator

    clicks already do this if you manage to click near enough to the displayed hr, there are just "empty" locations between the divider and any adjacent block element node that will end up being reconciled to a collapsed RangeSelection instead.

  6. niikkhilsharma-f commented on Oct 15, 2025

    @niikkhilsharma-f

    I think the expected behavior here would be to have clicks be handled in the basically same way that the arrow keys are, where it will switch to a NodeSelection of the HorizontalRuleNode instead of a specific position before or after the node.

    The click-to-select functionality for the HorizontalRuleNode is already implemented and working correctly when clicking directly on the horizontal rule element itself. However, there are noticeable empty spaces above and below the HorizontalRuleNode where clicking doesn't trigger the selection mechanism, creating problematic dead zones for user interaction.​

    I've noticed that applying overflow: hidden to the root contenteditable div appears to prevent the caret from visually moving downward when clicking in these empty spaces. This CSS solution could serve as a workaround to contain the caret within the expected editing boundaries, though it's worth testing for potential side effects on scrolling behavior.

  7. niikkhilsharma-f commented on Oct 15, 2025

    @niikkhilsharma-f

    An alternative approach would be to implement a custom click event listener that calculates the click position relative to the HorizontalRuleNode and programmatically sets the selection to either the node immediately before or after it, depending on which is closer. This would provide more precise control over selection behavior in the problematic regions by leveraging Lexical's $createRangeSelection() and $setSelection() APIs to handle these edge cases explicitly.

  8. Vedthakar commented on Oct 21, 2026

    @Vedthakar
    Contributor

    I opened #9422 to fix this: clicking the empty space above or below a horizontal rule now selects the rule, as the arrow keys do. It hit-tests the click against the rules' own boxes (with margins), so it doesn't depend on where the browser puts the caret.

    — Ved Thakar

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions