Skip to content

Commit

Permalink
APP-4361: remove tooltips from flow when invisible (viamrobotics#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Apr 22, 2024
1 parent 0ad67e3 commit 6cb17f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime-core",
"version": "0.0.112",
"version": "0.0.113",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ describe('Restricted Text Input', () => {
// Type a single invalid character, which shows the tooltip but does not wiggle
await user.type(input, 'a');

expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');
expect(tooltip).not.toHaveClass('animate-wiggle');
await waitFor(() => expect(tooltip).toHaveClass('invisible'));
await waitFor(() => expect(tooltip).toHaveClass('hidden'));

// Type multiple invalid characters, which shows the tooltip and wiggles
await user.type(input, 'aa');

expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');
expect(tooltip).toHaveClass('animate-wiggle');
await waitFor(() => expect(tooltip).not.toHaveClass('animate-wiggle'));
});
Expand Down
24 changes: 12 additions & 12 deletions packages/core/src/lib/tooltip/__tests__/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Tooltip', () => {
const tooltip = screen.getByRole('tooltip');

expect(target).toBeInTheDocument();
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
});

it('passes the tooltip ID to the target slot', () => {
Expand All @@ -34,15 +34,15 @@ describe('Tooltip', () => {
const tooltip = screen.getByRole('tooltip');

// tooltip should initially be invisible before styles calculate
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
// then it should become visible
await waitFor(() => expect(tooltip).not.toHaveClass('invisible'));

await user.hover(target);
expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');

await user.unhover(target);
expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');
});

it('does not render the tooltip when state is invisible', async () => {
Expand All @@ -54,14 +54,14 @@ describe('Tooltip', () => {
const tooltip = screen.getByRole('tooltip');

// tooltip should initially be invisible before styles calculate
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');

// tooltip should stay invisible despite hover state
await user.hover(target);
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');

await user.unhover(target);
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
});

it('shows/hides the tooltip on mouse enter/exit', async () => {
Expand All @@ -73,10 +73,10 @@ describe('Tooltip', () => {
const tooltip = screen.getByRole('tooltip');

await user.hover(target);
expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');

await user.unhover(target);
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
});

it('shows the tooltip on mouse enter after a delay', async () => {
Expand All @@ -88,7 +88,7 @@ describe('Tooltip', () => {
const tooltip = screen.getByRole('tooltip');

await user.hover(target);
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
await waitFor(() => expect(tooltip).not.toHaveClass('invisible'));
});

Expand All @@ -100,10 +100,10 @@ describe('Tooltip', () => {

await userEvent.tab();
expect(target).toHaveFocus();
expect(tooltip).not.toHaveClass('invisible');
expect(tooltip).not.toHaveClass('hidden');

await userEvent.tab();
expect(target).not.toHaveFocus();
expect(tooltip).toHaveClass('invisible');
expect(tooltip).toHaveClass('hidden');
});
});
2 changes: 1 addition & 1 deletion packages/core/src/lib/tooltip/tooltip-text.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $: style.register({
bind:this={floatingElement}
{id}
role="tooltip"
class:invisible={!$isVisible || !$style}
class:hidden={!$isVisible || !$style}
style:top={$style?.top}
style:left={$style?.left}
class={cx(
Expand Down

0 comments on commit 6cb17f8

Please sign in to comment.