Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

SelectionState hasEdgeWithin has a false positive case #1700

@andrewbranch

Description

@andrewbranch

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

Terminology: “target range” is the range described by the arguments to hasEdgeWithin.

When a SelectionState is confined to a single block, hasEdgeWithin returns true when one edge is before the target range and the other edge is after the target range. (I.e., a special case of neither edge being within the target range.)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

https://runkit.com/andrewbranch/5aac76e3315c160012a07b84

const selection = SelectionState.createEmpty('a').merge({
  anchorOffset: 0,
  focusOffset: 20
});

// currently returns true, even though neither 0 nor 20 is between 5 and 10
selection.hasEdgeWithin('a', 5, 10);

What is the expected behavior?

hasEdgeWithin returns false for all cases where neither selection edge is within the target range.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

The hasEdgeWithin algorithm hasn’t changed since Draft JS was open sourced.

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