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

Tooltip & DefinitionTooltip changed storybook and functionality #15887

Merged
merged 4 commits into from
Mar 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const { expect, test } = require('@playwright/test');
const { visitStory } = require('../../test-utils/storybook');

test.describe('DefinitionTooltip @avt', () => {
test.describe('@avt DefinitionTooltip', () => {
test('@avt-default-state', async ({ page }) => {
await visitStory(page, {
component: 'DefinitionTooltip',
Expand All @@ -24,7 +24,7 @@ test.describe('DefinitionTooltip @avt', () => {
);
});

test('@avt-keyboard-state default', async ({ page }) => {
test('@avt-keyboard-nav default', async ({ page }) => {
await visitStory(page, {
component: 'DefinitionTooltip',
id: 'components-definitiontooltip--default',
Expand All @@ -38,10 +38,10 @@ test.describe('DefinitionTooltip @avt', () => {
const primaryButton = page.getByRole('button', { name: 'URL' });

// Testing DefinitionTooltip
await page.keyboard.press('Tab');
await expect(primaryButton).toBeVisible();
await expect(primaryButton).toHaveAttribute('aria-expanded', 'false');
await primaryButton.click();
await page.keyboard.press('Tab');
await expect(primaryButton).toHaveAttribute('aria-expanded', 'true');
await primaryButton.click();
await expect(primaryButton).toHaveAttribute('aria-expanded', 'false');
});
});
3 changes: 3 additions & 0 deletions packages/react/src/components/Tooltip/DefinitionTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ const DefinitionTooltip: React.FC<DefinitionTooltipProps> = ({
onMouseEnter={() => {
openOnHover ? setOpen(true) : null;
}}
onFocus={() => {
setOpen(true);
}}
open={isOpen}>
<button
{...rest}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Tooltip/Tooltip.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const Playground = PlaygroundStory.bind({});
Playground.args = {
align: 'bottom',
closeOnActivation: false,
defaultOpen: true,
defaultOpen: false,
label: 'Custom label',
};

Expand Down
Loading