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

Including Text Content Now Filters For Text Content #6041

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

seanparsons
Copy link
Contributor

Problem:
In the example project it was observed that it is possible to highlight an element from outside its bounds.

Fix:
Elements that weren't text elements were being included in the content bounds.

Commit Details:

  • Changed the parameter withContent for getCanvasRectangleFromElement to make it clear that it means text content.
  • getCanvasRectangleFromElement filters for text nodes when including text content in the dimensions.

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Preview mode

Fixes #5984

- Changed the parameter `withContent` for `getCanvasRectangleFromElement`
  to make it clear that it means text content.
- `getCanvasRectangleFromElement` filters for text nodes when including
  text content in the dimensions.
Copy link
Contributor

github-actions bot commented Jul 4, 2024

Try me

Copy link

relativeci bot commented Jul 4, 2024

#13281 Bundle Size — 62.51MiB (~+0.01%).

64e5e64(current) vs 6339ece master#13279(baseline)

Warning

Bundle contains 51 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#13281
     Baseline
#13279
Regression  Initial JS 45.57MiB(~+0.01%) 45.57MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 21.69% 22.06%
No change  Chunks 30 30
No change  Assets 33 33
No change  Modules 4323 4323
No change  Duplicate Modules 524 524
No change  Duplicate Code 31.74% 31.74%
No change  Packages 450 450
No change  Duplicate Packages 51 51
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#13281
     Baseline
#13279
Regression  JS 62.5MiB (~+0.01%) 62.5MiB
Improvement  HTML 11.16KiB (-0.33%) 11.2KiB

Bundle analysis reportBranch fix/text-content-means-text-cont...Project dashboard

@seanparsons seanparsons marked this pull request as ready for review July 5, 2024 12:07
for (const childNode of element.childNodes) {
if (childNode.nodeType === Node.TEXT_NODE) {
const range = document.createRange()
// this is needed because jsdom can throw an error on the range.getBoundingClientRect() call, see https://github.com/jsdom/jsdom/issues/3002
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

@seanparsons seanparsons merged commit 32644fb into master Jul 9, 2024
3 checks passed
@seanparsons seanparsons deleted the fix/text-content-means-text-content branch July 9, 2024 10:18
liady pushed a commit that referenced this pull request Dec 13, 2024
- Changed the parameter `withContent` for
`getCanvasRectangleFromElement` to make it clear that it means text
content.
- `getCanvasRectangleFromElement` filters for text nodes when including
text content in the dimensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click target is wrong (repro needed)
3 participants