Repository navigation
Conversation
…ragments ## Description `createRectsFromDOMRange` may sort differently-sized inline fragments out of their text order. Its overlap filter previously checked only the preceding rect's right edge, so it could remove an adjacent fragment that did not overlap horizontally. Require horizontal overlap in both directions before filtering a rect. Closes meta#9184 ## Test plan ### Before Edge DOM Range reproduction: {"sourceFragments":2,"before":1} ### After Edge DOM Range reproduction: {"sourceFragments":2,"after":2} pnpm vitest --project unit --run ... -> 66 passed pnpm exec prettier --check ... -> passed pnpm exec eslint ... -> passed The repository Chromium browser test could not run locally because the Playwright Chromium executable was unavailable; the new browser regression test is included for CI.
|
Hi @yftx293! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
| prevRect.top <= selectionRect.top && | ||
| prevRect.top + prevRect.height > selectionRect.top && | ||
| prevRect.left + prevRect.width > selectionRect.left; | ||
| prevRect.left < selectionRect.right && |
There was a problem hiding this comment.
If I understand correctly, this checks if the block is actually to the left. However, I think we should fix the root cause instead - the array is expected to already be sorted by this point
| prevRect.top + prevRect.height > selectionRect.top && | ||
| prevRect.left + prevRect.width > selectionRect.left; | ||
| prevRect.left < selectionRect.right && | ||
| prevRect.right > selectionRect.left; |
There was a problem hiding this comment.
I'm not sure where the issue originated - whether it's an error in the math when adding prev.rect + prev.width or an issue with how clientRects is calculated. Because of that, I think we should add a 1px threshold here.
That said, I'm not a maintainer, so they might see it differently
There was a problem hiding this comment.
I don't think a 1px threshold is sufficient to fix this issue, there can be arbitrary partial overlaps between these rectangles.
Description
createRectsFromDOMRangemay sort differently-sized inline fragments out of their text order. Its overlap filter previously checked only the preceding rect's right edge, so it could remove an adjacent fragment that did not overlap horizontally.Require horizontal overlap in both directions before filtering a rect.
Closes #9184
Test plan
Before
Edge DOM Range reproduction:
{"sourceFragments":2,"before":1}
After
Edge DOM Range reproduction:
{"sourceFragments":2,"after":2}
pnpm vitest --project unit --run ... -> 66 passed
pnpm exec prettier --check ... -> passed
pnpm exec eslint ... -> passed
The repository Chromium browser test could not run locally because the Playwright Chromium executable was unavailable; the new browser regression test is included for CI.