Components: migrate Truncate to SCSS module#79446
Conversation
431e26d to
2763488
Compare
|
Size Change: +195 B (0%) Total Size: 7.51 MB 📦 View Changed
|
| expect( screen.getByRole( 'heading' ) ).toHaveStyle( { | ||
| textOverflow: 'ellipsis', | ||
| } ); | ||
| expect( screen.getByRole( 'heading' ) ).toHaveTextContent( 'L…' ); |
There was a problem hiding this comment.
Slightly changed the test here, switching from invoking the auto mode (which relies on CSS text-truncation and can't be tested) to the explicit limit + ellipsizeMode (which actually chanegs the content of the DOM element).
Sidenote: not in scope for this PR, but we should probably retain the whole text content for assistive technology all the time? Something to keep in mind for #77391
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
70caf03 to
2058bc5
Compare
|
Flaky tests detected in 2058bc5. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28168347114
|
* Components: migrate Truncate to SCSS module * Truncate: Refine SCSS module migration * Truncate: Update related test expectations * Text: Check truncate accessible name * Text: Remove truncation style assertion * Text: Restore character truncation test * Truncate: Address SCSS module review feedback --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
Part of #66806
What?
Migrates
Truncateaway from Emotion styles and onto an SCSS Module.Why?
This is one of the canary components for the refreshed Emotion migration plan. It validates a small static style migration plus a prop-driven CSS custom property replacement.
How?
styles.tsfile withstyle.module.scss.clsxfor class composition.numberOfLinesEmotion interpolation with--wp-components-truncate-lines.View; the View migration remains separate.Testing Instructions
npm run test:unit packages/components/src/truncate/test/index.tsx -- --runInBandnpm run lint:js -- packages/components/src/truncate/hook.ts packages/components/src/truncate/test/index.tsxnpm run lint:css -- packages/components/src/truncate/style.module.scss./node_modules/.bin/tsgo --build packages/components/tsconfig.jsongit diff --checkTesting Instructions for Keyboard
No keyboard-specific behavior changed.
Truncateis a non-interactive typography primitive.Screenshots or screencast
Not applicable; this should preserve the existing visual output.
Use of AI Tools
Used AI assistance to inspect the existing component implementation, apply the migration, and draft this PR description. The changes were reviewed and verified locally.