Skip to content

Commit

Permalink
fix(kbadge): tabindex when has tooltip (#2618)
Browse files Browse the repository at this point in the history
* fix(kbadge): tabindex when has tooltip

* fix: lint:fix
  • Loading branch information
portikM authored Feb 14, 2025
1 parent a3d610b commit 2d893b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/components/tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ A string to be used as `id` attribute on underlying `role="tooltip"` element. Us

The `default` slot takes in the element you want the popover to be triggered over.

:::tip NOTE
Make sure to set appropriate `tabindex` attribute on your tooltip trigger element in order to make popover accessible for assistive technology users.
:::

```html
<KTooltip text="A simple tooltip.">
<KButton>Button</KButton>
Expand Down
9 changes: 4 additions & 5 deletions src/components/KBadge/KBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
class="k-badge"
:class="[appearance, { 'method': isMethodBadge }]"
>
<component
:is="showTooltip ? 'KTooltip' : 'div'"
:text="showTooltip ? tooltip : undefined"
>
<KTooltip :text="showTooltip ? tooltip : undefined">
<div
class="badge-content"
:class="{ 'icon-after': !iconBefore }"
:tabindex="showTooltip ? 0 : undefined"
>
<slot
v-if="$slots.icon"
Expand All @@ -22,7 +20,7 @@
<slot />
</div>
</div>
</component>
</KTooltip>
</div>
</template>

Expand All @@ -40,6 +38,7 @@ const { getSizeFromString } = useUtilities()
// Must explicitly define components so KTooltip works in tests
export default {
name: 'KBadge',
// eslint-disable-next-line vue/no-unused-components
components: { KButton, KTooltip },
}
</script>
Expand Down

0 comments on commit 2d893b6

Please sign in to comment.