Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rect deduplication #4471

Merged
merged 3 commits into from
May 9, 2023
Merged

Improve rect deduplication #4471

merged 3 commits into from
May 9, 2023

Conversation

acywatson
Copy link
Contributor

@acywatson acywatson commented May 8, 2023

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
Copy link

vercel bot commented May 8, 2023

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
Copy link

github-actions bot commented May 8, 2023

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

@acywatson acywatson merged commit 29be910 into main May 9, 2023
43 checks passed
This was referenced May 23, 2023
@fantactuka fantactuka deleted the create-rects branch July 6, 2023 20:15
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.

None yet

3 participants