Skip to content

Use overflowEllipsisDeclarations when lines=1 - #7293

Open
bearfriend wants to merge 3 commits into
mainfrom
dgleckler/overflow-one-line
Open

Use overflowEllipsisDeclarations when lines=1#7293
bearfriend wants to merge 3 commits into
mainfrom
dgleckler/overflow-one-line

Conversation

@bearfriend

@bearfriend bearfriend commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PHNX-4815

In #7233 we adjusted the overflow clip margin to roughly follow the line-height to fix an issue with subsequent lines of text partially showing at the bottom of the clipped area. However, this only happens in Windows at mobile device widths (when we shrink the font-size and line-height) and when using line-clamp styles. This is unlikely to occur in real-world usage already, but this PR changes line=1 usages of getOverflowDeclarations to always use overflowEllipsisDeclarations instead of line-clamp which prevents this issue even further in the majority of uses.

If it later becomes a problem in production we can try some other changes like adjusting the font-face styles in Windows etc.

@bearfriend
bearfriend requested a review from GZolla July 30, 2026 17:42
@bearfriend
bearfriend requested a review from a team as a code owner July 30, 2026 17:42
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-7293/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Comment thread components/link/link.js
Comment on lines -160 to +153
const spanClasses = {
'd2l-link-content': true,
'truncate': this.lines > 1,
'truncate-one': this.lines === 1
};
const styles = { webkitLineClamp: this.lines || null };
const styles = this.lines ? getOverflowDeclarations({ lines: this.lines }) : null;

@bearfriend bearfriend Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of handling 1 and >1 lines cases with separate classes, we can use the same it seemed simpler to just apply the styles inline. Even though the same call gets us the correct style now, the stylesheet doesn't update with property changes so it needs to either happen on render, or go back to separate classes

Comment thread components/link/link.js Outdated
Comment thread helpers/overflow.js
export function getOverflowDeclarations({ textOverflow = '', lines = 0, lit = true } = {}) {
export function getOverflowDeclarations({ textOverflow = '', lines = 1, lit = true } = {}) {
if (!arguments.length) return overflowHiddenDeclarations;
if (arguments[0].lines === 1) return overflowEllipsisDeclarations;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this not ignore the textOverflow option?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also does just lines === 1 break? Or why do we need to use the args object?

@bearfriend bearfriend Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

arguments because we want to check what was passed in, not what was defaulted. It will ignore textOverflow because if you're passing lines that means you inherently are expecting the standard ellipses overflow. It would do that now already since that's the only way line-clamp renders. It sets it but doesn't do anything now.

@GZolla GZolla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other than the missing }, LGTM

Comment thread components/link/link.js
if (this.disabled) {
e.stopPropagation();
e.preventDefault();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That suggestion was impossible to get to render correctly and it still broke anyway after 3 tries

@bearfriend
bearfriend force-pushed the dgleckler/overflow-one-line branch from 3141fc1 to 3ec2de5 Compare July 30, 2026 19:06
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.

2 participants