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

fix(input-number): when zero is entered, value displayed isn't expected #5232

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

betavs
Copy link
Contributor

@betavs betavs commented Nov 3, 2023

Copy link

vercel bot commented Nov 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Nov 3, 2023 1:38pm

Copy link

github-actions bot commented Nov 3, 2023

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

@betavs
Copy link
Contributor Author

betavs commented Nov 3, 2023

If this solution works, I'll optimize the code again.

@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Nov 3, 2023
@melloware
Copy link
Member

@betavs so the only real change is this line?

inputEl.setSelectionRange(selectionEnd + 1, selectionEnd + 1);

to

inputEl.setSelectionRange(selectionEnd, selectionEnd);

???

@betavs
Copy link
Contributor Author

betavs commented Nov 3, 2023

@betavs so the only real change is this line?

inputEl.setSelectionRange(selectionEnd + 1, selectionEnd + 1);

to

inputEl.setSelectionRange(selectionEnd, selectionEnd);

???

Yes, but I think it can be optimized to

if (['insert', 'delete-back-single', 'delete-range', 'spin'].includes(operation)) {
    inputEl.setSelectionRange(selectionEnd, selectionEnd);
} else if (operation === 'delete-single') {
    inputEl.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
}

@melloware
Copy link
Member

OK can you update your PR for your optimization so I can test it.

Copy link

github-actions bot commented Nov 3, 2023

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

Copy link
Member

@melloware melloware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and looking good to me.

@melloware melloware merged commit fde9a58 into primefaces:master Nov 3, 2023
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InputNumber: Enter leading 0 when using prefix/suffix
2 participants