-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(*): remove vue-bind-once [KHCP-14269] #2535
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for kongponents-sandbox ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kongponents ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Co-authored-by: Adam DeHaven <[email protected]>
Preview package from this PR in consuming applicationIn consuming application project install preview version of kongponents generated by this PR:
|
@@ -110,7 +109,7 @@ const emit = defineEmits<{ | |||
const slots = useSlots() | |||
const attrs = useAttrs() | |||
|
|||
const inputId = attrs.id ? String(attrs.id) : useUniqueId() | |||
const inputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const inputId = attrs.id ? String(attrs.id) : useId() | |
const id = useId() | |
const inputId = computed(() => attrs.id ? String(attrs.id) : id) |
I think now this should be a computed ref as we now support dynamic user defined id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd name differently than id
just to not get confused with other properties, etc. Something like defaultId
might be more obvious
@@ -134,6 +134,8 @@ const emit = defineEmits<{ | |||
|
|||
const { stripRequiredLabel } = useUtilities() | |||
|
|||
const fileInputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
@@ -175,8 +175,8 @@ const slots = useSlots() | |||
const attrs = useAttrs() | |||
|
|||
const isRequired = computed((): boolean => attrs?.required !== undefined && String(attrs?.required) !== 'false') | |||
const inputId = attrs.id ? String(attrs.id) : useUniqueId() | |||
const helpTextId = useUniqueId() | |||
const inputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make these computed, but the useId()
call would need to be made outside of the computed function and then referenced, similar to this:
const defaultId = useId()
const inputId = computed((): string => attrs.id ? String(attrs.id) : defaultId)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have an example in my first comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yep I missed that one 👍🏼
@@ -100,7 +99,7 @@ const attrs = useAttrs() | |||
|
|||
const switchInputElement = ref<HTMLInputElement | null>(null) | |||
|
|||
const inputId = attrs.id ? String(attrs.id) : useUniqueId() | |||
const inputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
@@ -495,8 +495,8 @@ const defaultKPopAttributes = { | |||
const key = ref(0) | |||
const stagingKey = ref(0) | |||
|
|||
const multiselectWrapperId = attrs.id ? String(attrs.id) : useUniqueId() // unique id for the KLabel `for` attribute | |||
const multiselectKey = useUniqueId() | |||
const multiselectWrapperId = attrs.id ? String(attrs.id) : useId() // unique id for the KLabel `for` attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
@@ -177,7 +176,7 @@ const props = defineProps({ | |||
const slots = useSlots() | |||
const attrs = useAttrs() | |||
|
|||
const inputId = attrs.id ? String(attrs.id) : useUniqueId() | |||
const inputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
@@ -363,6 +364,8 @@ const emit = defineEmits<{ | |||
const attrs = useAttrs() | |||
const slots = useSlots() | |||
|
|||
const selectInputId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
@@ -161,7 +160,7 @@ const value = computed({ | |||
}, | |||
}) | |||
|
|||
const textAreaId = attrs.id ? String(attrs.id) : useUniqueId() | |||
const textAreaId = attrs.id ? String(attrs.id) : useId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
Summary
Addresses: https://konghq.atlassian.net/browse/KHCP-14269
Remove dependancy on
vue-bind-once
. In all components, rely on VueuseId
instead ofnanoid
for generating unique values for accessibility attributes.