Commit 81aa977
fix(input-otp): prevent deletion and paste when disabled or readonly (#30983)
Closes #30913
## Description
When `ion-input-otp` has the `readonly` prop set, typing is correctly
blocked but users are still able to delete characters using the
Backspace or Delete keys.
When `disabled` or `readonly` are set, users are still able to paste
into the component.
## Changes
- Added guard for `disabled` and `readonly` inside `onInput` and
`onPaste` handler
- Prevented default behavior for `Backspace` and `Delete` when
`readonly` is `true`
- Return in `onKeydown` when `disabled` is `true`
- Added e2e tests verifying the behavior
## How to Test
1. Add `readonly` to `ion-input-otp`
2. Attempt to type → no input allowed
3. Press Backspace/Delete → no characters removed
Behavior now matches expected readonly semantics.
---------
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>1 parent 00666a5 commit 81aa977
File tree
2 files changed
+84
-3
lines changed- core/src/components/input-otp
- test/basic
2 files changed
+84
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
542 | 553 | | |
543 | 554 | | |
544 | 555 | | |
| |||
603 | 614 | | |
604 | 615 | | |
605 | 616 | | |
606 | | - | |
| 617 | + | |
607 | 618 | | |
608 | 619 | | |
609 | 620 | | |
610 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
611 | 626 | | |
612 | 627 | | |
613 | 628 | | |
| |||
735 | 750 | | |
736 | 751 | | |
737 | 752 | | |
738 | | - | |
| 753 | + | |
739 | 754 | | |
740 | 755 | | |
741 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
742 | 761 | | |
743 | 762 | | |
744 | 763 | | |
| |||
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
690 | 715 | | |
691 | 716 | | |
692 | 717 | | |
| |||
737 | 762 | | |
738 | 763 | | |
739 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
740 | 780 | | |
741 | 781 | | |
742 | 782 | | |
| |||
828 | 868 | | |
829 | 869 | | |
830 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
831 | 893 | | |
832 | 894 | | |
833 | 895 | | |
| |||
0 commit comments