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

Component: Otp Input Component does not focus next element when TAB is pressed in last input #16653

Open
rehdie opened this issue Oct 28, 2024 · 0 comments · May be fixed by #16655
Open

Component: Otp Input Component does not focus next element when TAB is pressed in last input #16653

rehdie opened this issue Oct 28, 2024 · 0 comments · May be fixed by #16655
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working v18-port
Milestone

Comments

@rehdie
Copy link

rehdie commented Oct 28, 2024

Describe the bug

When all input fields are filled and you want to move to the next form-element via TAB-key, nothing happens.

The reason is, that the method onKeyDown calls preventDefault in this case,

As a workaround I've done the following:

<p-inputOtp ...>
   <ng-template  pTemplate="input" let-token let-events="events">
      <input 
         pInputText
         (keydown)="onOtpKeydown(events, $event)"
         ....>
   </ng-template>
</p-inputOtp>

And in the component class:

 onOtpKeydown(templateEvents: InputOtpTemplateEvents, event: KeyboardEvent) {
    if(event.key==="Tab") {
        return;
    }
    templateEvents.keydown(event);
  }

This solution also allows the TAB-key to navigate between the multiple-input-fields. If you don't want that, you would have to pass the index as well and do that on the last field only.

Environment

Windows 10
Angular 18.2.0
MS Edge 128.0.2739.63
Firefox 128.2.0esr

Reproducer

No response

Angular version

Angular 18.2.0

PrimeNG version

17.18.10

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.18.0

Browser(s)

MS Edge 128.0.2739.63

Steps to reproduce the behavior

No response

Expected behavior

No response

@rehdie rehdie added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 28, 2024
@rehdie rehdie changed the title Component: Otp Input Component Component: Otp Input Component does not focus next element when TAB is pressed in last input Oct 28, 2024
mateuszstudentzero pushed a commit to mateuszstudentzero/primeng-zio that referenced this issue Oct 28, 2024
@mateuszstudentzero mateuszstudentzero linked a pull request Oct 28, 2024 that will close this issue
mateuszstudentzero pushed a commit to mateuszstudentzero/primeng-zio that referenced this issue Oct 28, 2024
mateuszstudentzero pushed a commit to mateuszstudentzero/primeng-zio that referenced this issue Oct 28, 2024
@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 Nov 18, 2024
@mertsincan mertsincan added this to the 17.18.13 milestone Nov 18, 2024
@mertsincan mertsincan linked a pull request Nov 18, 2024 that will close this issue
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 v18-port
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants