Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fix(Tooltip): remove the wrapper div from activator slot
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Oct 30, 2023
1 parent a24350a commit dca6ae3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions example/cypress/e2e/overlays/tooltip.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Tooltip', () => {

cy.get('div[data-cy=tooltip-0]').as('defaultTooltip');

cy.get('@defaultTooltip').find('div[class*=_activator_]');
cy.get('@defaultTooltip').find('[data-cy=activator]');
cy.get('@defaultTooltip').trigger('mouseover');
cy.get('body').find('div[role=tooltip]');
cy.get('@defaultTooltip').trigger('mouseleave');
Expand All @@ -20,7 +20,7 @@ describe('Tooltip', () => {
it('checks for and trigger arrow tooltip', () => {
cy.get('div[data-cy=tooltip-4]').as('tooltipWithArrow');

cy.get('@tooltipWithArrow').find('div[class*=_activator_]');
cy.get('@tooltipWithArrow').find('[data-cy=activator]');
cy.get('@tooltipWithArrow').trigger('mouseover');
cy.get('body').find('div[role=tooltip]').as('tooltip');
cy.get('@tooltip').find('span[data-popper-arrow]');
Expand All @@ -32,7 +32,7 @@ describe('Tooltip', () => {
it('disabled should not trigger tooltip', () => {
cy.get('div[data-cy=tooltip-8]').as('disabledTooltip');

cy.get('@disabledTooltip').find('div[class*=_activator_]');
cy.get('@disabledTooltip').find('[data-cy=activator]');
cy.get('@disabledTooltip').trigger('mouseover');
cy.get('body').find('div[role=tooltip-content]').should('not.exist');
});
Expand Down
2 changes: 1 addition & 1 deletion example/src/views/TooltipView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const tooltips = ref<
:data-cy="`tooltip-${i}`"
>
<template #activator>
<RuiButton :color="tooltip.buttonColor">
<RuiButton data-cy="activator" :color="tooltip.buttonColor">
{{ tooltip.buttonText }}
</RuiButton>
</template>
Expand Down
6 changes: 4 additions & 2 deletions src/components/overlays/tooltip/Tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const createWrapper = (options?: any) =>
mount(Tooltip, {
...options,
slots: {
activator: { template: '<rui-button>Tooltip trigger</rui-button>' },
activator: {
template: '<rui-button id="trigger">Tooltip trigger</rui-button>',
},
default: options?.props?.text ?? '',
},
stubs: { RuiButton: Button },
Expand Down Expand Up @@ -50,7 +52,7 @@ describe('Tooltip', () => {
disabled: true,
},
});
expect(wrapper.get('div[class*=_activator_]')).toBeTruthy();
expect(wrapper.get('#trigger')).toBeTruthy();
expect(document.body.querySelector('div[role=tooltip]')).toBeFalsy();
wrapper.destroy();
});
Expand Down
10 changes: 1 addition & 9 deletions src/components/overlays/tooltip/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ const {
@mouseover="onMouseOver()"
@mouseleave="onMouseLeave()"
>
<div :class="css.activator">
<slot name="activator" :open="open" />
</div>
<slot name="activator" :open="open" />

<RuiTeleport v-if="!disabled">
<div
Expand Down Expand Up @@ -101,12 +99,6 @@ const {
$arrowSize: 0.625rem;
.wrapper {
@apply relative inline-flex;
.activator {
@apply inline;
width: inherit;
}
}
.tooltip {
Expand Down

0 comments on commit dca6ae3

Please sign in to comment.