Skip to content

Commit 4128efb

Browse files
fix: set default max-width: 40ch on the tooltip overlay (#4833) (#4838)
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
1 parent 24762ee commit 4128efb

5 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/tooltip/src/vaadin-tooltip-overlay.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
1010
registerStyles(
1111
'vaadin-tooltip-overlay',
1212
css`
13+
[part='overlay'] {
14+
max-width: 40ch;
15+
}
16+
1317
:host([position^='top'][top-aligned]) [part='overlay'],
1418
:host([position^='bottom'][top-aligned]) [part='overlay'] {
1519
margin-top: var(--vaadin-tooltip-offset-top, 0);
8.28 KB
Loading

‎packages/tooltip/test/visual/lumo/tooltip.test.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,19 @@ describe('tooltip', () => {
4444
document.documentElement.setAttribute('theme', 'dark');
4545
});
4646

47+
after(() => {
48+
document.documentElement.removeAttribute('theme');
49+
});
50+
4751
it('theme-dark', async () => {
4852
fire(target, 'mouseenter');
4953
await visualDiff(div, 'theme-dark');
5054
});
5155
});
56+
57+
it('max-width', async () => {
58+
element.text = 'This is a tooltip with a long text (more than 40 chars), it should wrap in 2 lines for readability';
59+
fire(target, 'mouseenter');
60+
await visualDiff(div, 'max-width');
61+
});
5262
});
6.81 KB
Loading

‎packages/tooltip/test/visual/material/tooltip.test.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ describe('tooltip', () => {
4747
document.documentElement.setAttribute('theme', 'dark');
4848
});
4949

50+
after(() => {
51+
document.documentElement.removeAttribute('theme');
52+
});
53+
5054
it('theme-dark', async () => {
5155
fire(target, 'mouseenter');
5256
await visualDiff(div, 'theme-dark');
5357
});
5458
});
59+
60+
it('max-width', async () => {
61+
element.text = 'This is a tooltip with a long text (more than 40 chars), it should wrap in 2 lines for readability';
62+
fire(target, 'mouseenter');
63+
await visualDiff(div, 'max-width');
64+
});
5565
});

0 commit comments

Comments
 (0)