Skip to content
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

Pin Input Number only #566

Closed
GimpMaster opened this issue Jun 5, 2024 · 3 comments · May be fixed by #469
Closed

Pin Input Number only #566

GimpMaster opened this issue Jun 5, 2024 · 3 comments · May be fixed by #469
Labels
enhancement An improvement to an existing feature/component Svelte 5 Roadmap This issue is planned to be addressed or fixed when the library migrates to Svelte 5.

Comments

@GimpMaster
Copy link

Describe the feature in detail (code, mocks, or screenshots encouraged)

Is it possible to make the pin input accept only a number. If we did this then when viewing it on a phone with the keyboard we would get the number pad only. Right now its a pain since each time you type a character, you have to select Number mode, press one number, then keyboard jumps back to qwerty keyboard

What type of pull request would this be?

None

Provide relevant links or additional information.

No response

@NDOY3M4N
Copy link
Contributor

NDOY3M4N commented Jun 5, 2024

I think this issue should be fixed in Melt UI. Actually someone already created an issue there and they gave him a temporary workaround. Here's the simplified version for Bits UI components.

<script lang="ts">
	import { PinInput } from "bits-ui";

	let value: string[] | undefined = [];

	let pinInputType: "text" | "password" | "number" = "number";
</script>

<!-- NOTE: this will throw a ts error on the type props, but it's just a workaround -->
<PinInput.Root bind:value type={pinInputType} placeholder="0">
  ...
</PinInput.Root>

@GimpMaster
Copy link
Author

Thank you. It seems like it works. I had to trick it into letting the typescript error get around.

One thing I noticed is that melt-ui uses the setSelectionRange which doesn't work with number inputs. Maybe that is why they never implemented numbers? Here is the error I get. It still works however.

Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.

You are right this is probably more of a melt-ui feature that needs to get thought out.

@huntabyte huntabyte mentioned this issue Jun 20, 2024
3 tasks
@huntabyte huntabyte added Svelte 5 Roadmap This issue is planned to be addressed or fixed when the library migrates to Svelte 5. feature request New feature request enhancement An improvement to an existing feature/component and removed feature request New feature request labels Jun 27, 2024
@huntabyte huntabyte mentioned this issue Jul 31, 2024
70 tasks
@huntabyte
Copy link
Owner

Closed as implemented in bits-ui@next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to an existing feature/component Svelte 5 Roadmap This issue is planned to be addressed or fixed when the library migrates to Svelte 5.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants