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

InputMask: Passed props are not set #6025

Closed
SwitzerChees opened this issue Jul 8, 2024 · 10 comments
Closed

InputMask: Passed props are not set #6025

SwitzerChees opened this issue Jul 8, 2024 · 10 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@SwitzerChees
Copy link

Describe the bug

Properties like id or name are not passed through anymore to the native rendered input of type text.
The problem can be reproduced or seen directly in the official documentation:
V4 Documentation (https://primevue.org/inputmask/):

<div class="flex-auto">
    <label for="phone" class="font-bold block mb-2">Phone</label>
    <InputMask id="phone" v-model="value2" mask="(999) 999-9999" placeholder="(999) 999-9999" fluid />
</div>

The rendered native input element is missing the id="phone" prop:
image

V3 Documentation (https://v3.primevue.org/inputmask/):

<div class="flex-auto">
    <label for="phone" class="font-bold block mb-2">Phone</label>
    <InputMask id="phone" v-model="value2" mask="(999) 999-9999" placeholder="(999) 999-9999" />
</div>

The rendered native input element has the id="phone" prop:
image

This problem not only exists on the official documentation website but also when I use the component directly in my own application.

Reproducer

https://stackblitz.com/edit/primevue-4-vite-issue-template-yzbded?file=src%2FApp.vue

PrimeVue version

4.0.0

Vue version

4.x

Language

TypeScript

Build / Runtime

Nuxt

Browser(s)

No response

Steps to reproduce the behavior

  1. use InputMask component

  2. define id or name property in the input mask
    image

  3. check the rendered html output and check if they are missing.
    image

Expected behavior

The same behaviour like on V3 and as described in the following part of the documentation (https://primevue.org/inputmask/#accessibility):

InputMask component renders a native input element that implicitly includes any passed prop.

@SwitzerChees SwitzerChees added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 8, 2024
@mertsincan
Copy link
Member

Interesting! Do you get an error on console?

@mertsincan mertsincan added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 8, 2024
@mertsincan mertsincan added this to the 4.0.1 milestone Jul 8, 2024
@SwitzerChees
Copy link
Author

No there are no errors in the console, not on the official documentation page (https://primevue.org/inputmask/) and also not in my own application when I use the InputMask.

Back in V3 a native input element was used with v-bind:
https://github.com/primefaces/primevue/blob/v3-prod/components/lib/inputmask/InputMask.vue
image

Now in the V4 there is now the :pt used from the InputText component:
https://github.com/primefaces/primevue/blob/master/packages/primevue/src/inputmask/InputMask.vue
image
and props like placeholder and class have their own props now.

maybe something in the passthrough logic doesn't work as expected?

@mertsincan
Copy link
Member

Thanks a lot! We'll fix it in the next version.

@vanpyrzericj
Copy link

Just want to add onto this that being able to pass the type attribute (which we can do for <InputText>) would also be ideal, in addition to the OP's attributes.

This is helpful when, for example, an input mask of a phone number is added, where we want to set type="tel" for mobile keyboards to display the numeric keypad.

@tugcekucukoglu
Copy link
Member

New pt usage of InputMask:

<InputMask
            :pt="{
                pcInputText: {
                    root: 'className'
                }
            }"
        />

@luke-z
Copy link

luke-z commented Jul 22, 2024

@tugcekucukoglu
Isn't it a bit of an anti-pattern to place the id property inside a passthrough property instead of directly on the custom HTML element, which adds it to the input element?

@SwitzerChees
Copy link
Author

That doesn't resolve the issue. Please check on your OWN documentation page the error remains even on your own page:
https://primevue.org/inputmask/#mask

image

And the rendered native input element doesn't have the id anymore.

image

If there is now a way to pass through attributes with PT then it would also make sense to update your own documentation ;-).

@tugcekucukoglu
Copy link
Member

@luke-z agree with you.

@SwitzerChees id property problem is obvious and there is no link with pt property.

Could you create an issue about this defect? I can fix it for the next version.

@SamuelWei
Copy link

@SwitzerChees I copied most of this issue and create a new one as @tugcekucukoglu asked for: #6100

@SwitzerChees
Copy link
Author

@SamuelWei that's great thank you 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

6 participants