Skip to content

Improve rect deduplication - #4471

Merged
acywatson merged 3 commits into
mainfrom
create-rects
May 9, 2023
Merged

acywatson merged 3 commits into
mainfrom
create-rects

Conversation

@acywatson

@acywatson acywatson commented May 8, 2023 •

Copy link
Copy Markdown
Contributor

This function helps creates a "fake" selection by getting all the rects for a given range, then creating a span tag for each that we layer over the rect position. For reasons that are not completely clear to me, the browser sometimes gives us what amount to "duplicate" rects for our purposes - Rects that completely or partially overlap and cause visual issues like a darker colored selection.

This PR is an effort to improve our deduplication logic to better detect these overlaps, which don't always have exactly matching top, left, width, and height properties. The approach here is instead to try to figure out of the top left corner of a given rect is inside of the previous rect when traversing the rects in order from top-left to bottom-right.

Before:
Screenshot 2023-05-08 at 3 48 56 PM

After:

Screenshot 2023-05-08 at 3 49 16 PM

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 8, 2023
@vercel

vercel Bot commented May 8, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2023 10:43pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2023 10:43pm

@github-actions

github-actions Bot commented May 8, 2023 •

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 27.2 KB (0%) 544 ms (0%) 242 ms (-18.8% 🔽) 786 ms
packages/lexical-rich-text/dist/LexicalRichText.js 38.14 KB (+0.1% 🔺) 763 ms (+0.1% 🔺) 653 ms (+88.9% 🔺) 1.5 s
packages/lexical-plain-text/dist/LexicalPlainText.js 38.12 KB (+0.1% 🔺) 763 ms (+0.1% 🔺) 343 ms (-25.32% 🔽) 1.2 s

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 6c7f6e89 Deployed May 8, 2023 by vercel[bot]
Preview – lexical — 6c7f6e89 Deployed May 8, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants