Skip to content

Commit

Permalink
fix(Icon): revert to last head
Browse files Browse the repository at this point in the history
fixes #18482 and #18493
  • Loading branch information
tmasrat committed Jan 25, 2024
1 parent dd32fc6 commit 837aad9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion packages/vuetify/src/components/VField/VField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { makeRoundedProps, useRounded } from '@/composables/rounded'
import { makeThemeProps, provideTheme } from '@/composables/theme'

// Utilities
import { computed, ref, toRef, watch } from 'vue'
import { computed, provide, ref, toRef, watch } from 'vue'
import {
animate,
convertToUnit,
Expand Down Expand Up @@ -154,6 +154,15 @@ export const VField = genericComponent<new <T>(
: props.baseColor
}))

if (props.clearable) {
const hasClickEvent = () => {
return Object.keys(attrs).some(key => {
return /^onclick/i.test(key) && attrs[key]
})
}
provide('hasClickEvent', hasClickEvent)
}

watch(isActive, val => {
if (hasLabel.value) {
const el: HTMLElement = labelRef.value!.$el
Expand Down
11 changes: 8 additions & 3 deletions packages/vuetify/src/components/VIcon/VIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { makeTagProps } from '@/composables/tag'
import { makeThemeProps, provideTheme } from '@/composables/theme'

// Utilities
import { computed, ref, Text, toRef } from 'vue'
import { computed, inject, ref, Text, toRef } from 'vue'
import { convertToUnit, flattenFragments, genericComponent, propsFactory, useRender } from '@/util'

export const makeVIconProps = propsFactory({
Expand Down Expand Up @@ -38,6 +38,10 @@ export const VIcon = genericComponent()({
const { sizeClasses } = useSize(props)
const { textColorClasses, textColorStyles } = useTextColor(toRef(props, 'color'))

const hasClickEvent = inject<() => boolean>('hasClickEvent')
// handle undefined
const safeHasClickEvent = hasClickEvent ?? (() => false)

useRender(() => {
const slotValue = slots.default?.()
if (slotValue) {
Expand Down Expand Up @@ -72,8 +76,9 @@ export const VIcon = genericComponent()({
textColorStyles.value,
props.style,
]}
role={ attrs.onClick ? 'button' : undefined }
aria-hidden={ !attrs.onClick }
role={ safeHasClickEvent() || attrs.onClick ? 'button' : undefined }
aria-hidden={ !safeHasClickEvent() || !attrs.onClick }
tabindex={ safeHasClickEvent() ? '0' : undefined }
>
{ slotValue }
</iconData.value.component>
Expand Down

0 comments on commit 837aad9

Please sign in to comment.