Skip to content

Improve selection.isCollapsed #337

@abhish-shrivastava

Description

@abhish-shrivastava

The selection.isCollapsed works by detecting start and end nodes and their offsets. This sometimes leads to inconsistencies because of different implementations by different browsers (especially on mobiles, tested this on chrome). Here is what happens-

  1. When a cursor is placed at the beginning of a list, the selection.isCollapsed should ideally return true and selection.type as 'cursor'.
  2. However, if there is text (say a paragraph block previously to the list), then it still gives false because startContainer is then taken as the previous text block (while end container points correctly to the list item, li of the list). So even though nothing is selected and it is just a cursor, selection.isCollapsed returns false and selection.type as 'range'.

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