-
Notifications
You must be signed in to change notification settings - Fork 779
fix(PinInput): remove default generic type
#4346
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
base: v3
Are you sure you want to change the base?
Conversation
commit: |
@@ -46,7 +46,7 @@ export type PinInputEmits<T extends PinInputType = 'text'> = PinInputRootEmits<T | |||
|
|||
</script> | |||
|
|||
<script setup lang="ts" generic="T extends PinInputType = 'text'"> | |||
<script setup lang="ts" generic="T extends PinInputType"> |
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.
Indeed, this change is necessary there should be no default here. However, the playground should work with just string[]
since the default type is text
π€
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.
That's what I was looking into but not there are no string[] | number[]
definition. The Reka UI component defines it like this: type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]
. This should work, I'm confused π
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.
I've looked into this as well, and it does correctly infer the type of the complete event when type="text" is explicitly specified, like in <UPinInput type="text" @ complete="onComplete" />.
However, I'm also unsure why TypeScript fails to infer the correct type when relying on the default type value.
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.
@benjamincanac
Additionally, could you let me know the estimated release schedule for the version that includes reka-ui 2.3.1 (e.g., 3.1.4)?
Currently, it seems there's an issue where, in the current version, when the PinInput type is set to number, trying to clear the value results in it changing to 0 instead of being cleared.
type
type
type
π Linked issue
β Type of change
π Description
This PR updates the PinInput component to support 'number' as a valid value for the type prop.
Previously, the component only accepted 'text', which limited use cases where numeric input was desired (e.g., PIN codes, OTPs). While the documentation suggested that both 'text' and 'number' were supported, the actual type definition restricted the type prop to string onlyβresulting in a TypeScript error when attempting to use type="number".
This fix corrects the type definition to explicitly allow both 'text' and 'number', aligning the implementation with the documented behavior and ensuring type safety without affecting existing functionality.
Changes include:
defineProps
to explicitly support both'text'
and'number'
typesπ Checklist