bug: ion-input not updating value if space trimmed equivalent of value changes
See original GitHub issueBug Report
Ionic version: [x] 4.11.4
Current behavior:
When setting an ion-input
’s value to a trimmed version of its previous value, the input does not recognize the value change. Therefore, there is no way to enforce input value trimming while typing inside an ion-input
or after leaving an ion-input
.
Expected behavior:
Setting the value of an ion-input
should accept any string and update accordingly.
Steps to reproduce:
- Initialize an ion-input on the page.
- Listen to the ionInput event.
- Inside the inputInput event, set the input’s value to a trimmed version of its own value.
Related code:
JS FIDDLE: https://jsfiddle.net/kpe14jwz/3/
<ion-item>
<ion-label position="floating">Type here</ion-label>
<ion-input id="ionInput"></ion-input>
</ion-item>
document.getElementById('ionInput')
.addEventListener('ionInput', (e) => {
e.target.value = e.target.value.trim();
});
Ionic Info:
N/A. Working out of jsfiddle with CDN.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
angular - ionic:Change event is not fired on <ion-input> when ...
I am changing input value from one of external javascript file. $('.scoreboardus input').val(200).trigger('onchange');.
Read more >ion-input: Custom Input Value Type Styling and CSS Properties
ion-input is a wrapper to the HTML input element, with custom value type styling ... The error slot will not be displayed unless...
Read more >App Rejected - Ion-Input Login Iss… | Apple Developer Forums
I have tested inputting the credentials using a real device and iOS simulator with no issues (including copy/pasting the provided values).
Read more >How to Trim the Value of Angular's Form Control - Netanel Basal
First, Angular's email validator performs the validation without trimming the value. In some cases, users accidentally add whitespace to the ...
Read more >SIMION 8.0 Issues/Bugs/Enhancements
if no change has been made. Issue I82 2005-12-10 [gui,resolved] "browse files" on main screen shows directories but no files. Resolved in some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still an issue in Ionic 5
Thanks for the issue. This appears to be a regression that appeared in Ionic 4.6.0, so I will mark this as a bug.
Example in Ionic 4.5.0: https://codepen.io/liamdebeasi/pen/RwwBYop Example in Ionic 4.6.0: https://codepen.io/liamdebeasi/pen/YzzjONN
As a temporary workaround you can do something like: