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

fix: ellipsis with maxWidth #542

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,15 @@ export default async function* buildTextNodes(
}
flow(r)
measuredTextSize = { width: r, height }
return { width: r, height }
return { width: Math.ceil(r), height }
}

measuredTextSize = { width, height }
return { width, height }
// This may be a temporary fix, I didn't dig deep into yoga.
// But when the return value of width here doesn't change (assuming the value of width is 216.9),
// when we later get the width through `parent.getComputedWidth()`, sometimes it returns 216 and sometimes 217.
// I'm not sure if this is a yoga bug, but it seems related to the entire page width.
// So I use Math.ceil.
return { width: Math.ceil(width), height }
})

const [x, y] = yield
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('Basic', () => {
display: 'flex',
height: '100%',
width: '100%',
background: 'white',
}}
>
Hi {0} <div>hi</div> {0} {false} {undefined} {0} {null} {0} {true} {'x'}{' '}
Expand Down
2 changes: 1 addition & 1 deletion test/event.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Event', () => {
"textContent": "World",
"top": 0,
"type": "div",
"width": 41,
"width": 42,
},
]
`)
Expand Down