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: set default max-width: 40ch on the tooltip overlay #4833

Merged
merged 1 commit into from
Oct 25, 2022
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
4 changes: 4 additions & 0 deletions packages/tooltip/src/vaadin-tooltip-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
registerStyles(
'vaadin-tooltip-overlay',
css`
[part='overlay'] {
max-width: 40ch;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably really pedantic but should there be some upper bound as well to make sure it doesn't have the full width on mobile / smaller / zoomed view ports? Like using 90% as well like Rolf had in his original idea?

Copy link
Member

Choose a reason for hiding this comment

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

I assume the re is a "safe area" around the overlay already, so there shouldn't be a need to limit the width, as it will never be 100% wide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Quick test on the sample in docs (without this max-width) does seem to indicate that, yes
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Thanks 🙇‍♂️

}

:host([position^='top'][top-aligned]) [part='overlay'],
:host([position^='bottom'][top-aligned]) [part='overlay'] {
margin-top: var(--vaadin-tooltip-offset-top, 0);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/tooltip/test/visual/lumo/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,19 @@ describe('tooltip', () => {
document.documentElement.setAttribute('theme', 'dark');
});

after(() => {
document.documentElement.removeAttribute('theme');
});

it('theme-dark', async () => {
fire(target, 'mouseenter');
await visualDiff(div, 'theme-dark');
});
});

it('max-width', async () => {
element.text = 'This is a tooltip with a long text (more than 40 chars), it should wrap in 2 lines for readability';
fire(target, 'mouseenter');
await visualDiff(div, 'max-width');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions packages/tooltip/test/visual/material/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ describe('tooltip', () => {
document.documentElement.setAttribute('theme', 'dark');
});

after(() => {
document.documentElement.removeAttribute('theme');
});

it('theme-dark', async () => {
fire(target, 'mouseenter');
await visualDiff(div, 'theme-dark');
});
});

it('max-width', async () => {
element.text = 'This is a tooltip with a long text (more than 40 chars), it should wrap in 2 lines for readability';
fire(target, 'mouseenter');
await visualDiff(div, 'max-width');
});
});