Skip to content

fix(tooltip): max-width specificity issue #5611

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .changeset/bright-trams-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spectrum-web-components/tooltip': patch
---

**Fixed** : tooltip max-width specificity issue
72 changes: 55 additions & 17 deletions packages/help-text/test/help-text.test.ts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these changes to help text intentional? Do they need to be documented at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is intentional to increase the code coverage. No code is harmed with this change.

Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,76 @@ import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
import '@spectrum-web-components/help-text/sp-help-text.js';
import { HelpText } from '@spectrum-web-components/help-text';
import { testForLitDevWarnings } from '../../../test/testing-helpers.js';
import { HelpTextManager } from '../src/HelpTextManager.js';

describe('HelpText', () => {
testForLitDevWarnings(
async () =>
await fixture<HelpText>(
html`
<sp-help-text>This is help text.</sp-help-text>
`
)
await fixture<HelpText>(html`
<sp-help-text>This is help text.</sp-help-text>
`)
);
it('loads default help-text accessibly', async () => {
const el = await fixture<HelpText>(
html`
<sp-help-text>This is help text.</sp-help-text>
`
);
const el = await fixture<HelpText>(html`
<sp-help-text>This is help text.</sp-help-text>
`);

await elementUpdated(el);

await expect(el).to.be.accessible();
});
it('loads negative/icon help-text accessibly', async () => {
const el = await fixture<HelpText>(
html`
<sp-help-text variant="negative" icon>
This is negative help text.
</sp-help-text>
`
);
const el = await fixture<HelpText>(html`
<sp-help-text variant="negative" icon>
This is negative help text.
</sp-help-text>
`);

await elementUpdated(el);

await expect(el).to.be.accessible();
});

describe('HelpTextManager', () => {
let manager: HelpTextManager;
let host: HTMLElement;

beforeEach(() => {
host = document.createElement('div');
document.body.appendChild(host);
manager = new HelpTextManager(host, { mode: 'external' });
});

afterEach(() => {
if (host.parentNode) {
host.parentNode.removeChild(host);
}
});

it('creates manager with correct id format', () => {
expect(manager.id).to.match(/^sp-help-text-/);
});

it('renders template with correct structure', () => {
const template = manager.render();
expect(template).to.be.instanceOf(Object);
});

it('renders negative template when negative is true', () => {
const template = manager.render(true);
expect(template).to.be.instanceOf(Object);
});

it('has correct mode setting', () => {
const externalManager = new HelpTextManager(host, {
mode: 'external',
});
const internalManager = new HelpTextManager(host, {
mode: 'internal',
});

expect(externalManager).to.be.instanceOf(HelpTextManager);
expect(internalManager).to.be.instanceOf(HelpTextManager);
});
});
});
1 change: 0 additions & 1 deletion packages/tooltip/src/tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#tooltip {
width: fit-content;
white-space: initial;
max-width: var(--spectrum-tooltip-max-inline-size);
}

#tip {
Expand Down
Loading