Skip to content

Commit

Permalink
refactor(tooltip): move trigger as first child (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlmoravek authored Sep 17, 2024
1 parent c6bd1bc commit fc6584f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ exports[`OSlider tests > render correctly 1`] = `
-->
<div class="o-slide__thumb-wrapper" style="left: 0%;" data-oruga="slider-thumb">
<div class="o-tip" data-oruga="tooltip">
<!--teleport start-->
<transition-stub name="fade" appear="false" persisted="true" css="true">
<div class="o-tip__content o-tip__content--auto" style="display: none;"><span class="o-tip__arrow o-tip__arrow--auto"></span>
<!--
@slot Tooltip content, default is label prop
-->0
</div>
</transition-stub>
<!--teleport end-->
<div class="o-tip__trigger" aria-haspopup="true">
<!--
@slot Tooltip trigger slot
Expand All @@ -28,6 +19,15 @@ exports[`OSlider tests > render correctly 1`] = `
<!--v-if-->
</div>
</div>
<!--teleport start-->
<transition-stub name="fade" appear="false" persisted="true" css="true">
<div class="o-tip__content o-tip__content--auto" style="display: none;"><span class="o-tip__arrow o-tip__arrow--auto"></span>
<!--
@slot Tooltip content, default is label prop
-->0
</div>
</transition-stub>
<!--teleport end-->
</div>
</div>
<!--v-if-->
Expand Down
36 changes: 18 additions & 18 deletions packages/oruga/src/components/tooltip/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,24 @@ const contentClasses = defineClasses(

<template>
<div :class="rootClasses" data-oruga="tooltip">
<component
:is="triggerTag"
ref="triggerRef"
:class="triggerClasses"
aria-haspopup="true"
@click="onClick"
@contextmenu="onContextMenu"
@mouseenter="onHover"
@focus.capture="onFocus"
@blur.capture="onClose"
@mouseleave="onClose">
<!--
@slot Tooltip trigger slot
@binding {boolean} active - tooltip active state
-->
<slot :active="isActive" />
</component>

<PositionWrapper
v-slot="{ setContent }"
v-model:position="autoPosition"
Expand All @@ -376,23 +394,5 @@ const contentClasses = defineClasses(
</div>
</transition>
</PositionWrapper>

<component
:is="triggerTag"
ref="triggerRef"
:class="triggerClasses"
aria-haspopup="true"
@click="onClick"
@contextmenu="onContextMenu"
@mouseenter="onHover"
@focus.capture="onFocus"
@blur.capture="onClose"
@mouseleave="onClose">
<!--
@slot Tooltip trigger slot
@binding {boolean} active - tooltip active state
-->
<slot :active="isActive" />
</component>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

exports[`OTooltip tests > render correctly 1`] = `
"<div class="o-tip" data-oruga="tooltip">
<div class="o-tip__trigger" aria-haspopup="true">
<!--
@slot Tooltip trigger slot
@binding {boolean} active - tooltip active state
-->
</div>
<!--teleport start-->
<transition-stub name="fade" appear="false" persisted="true" css="true">
<div class="o-tip__content o-tip__content--auto" style="display: none;"><span class="o-tip__arrow o-tip__arrow--auto"></span>
Expand All @@ -11,11 +17,5 @@ exports[`OTooltip tests > render correctly 1`] = `
</div>
</transition-stub>
<!--teleport end-->
<div class="o-tip__trigger" aria-haspopup="true">
<!--
@slot Tooltip trigger slot
@binding {boolean} active - tooltip active state
-->
</div>
</div>"
`;

0 comments on commit fc6584f

Please sign in to comment.