Skip to content

Commit 559109d

Browse files
authored
fix(ui5-input): inputs now support placeholder on IE (#781)
1 parent b5d8fde commit 559109d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

packages/main/src/Input.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
?readonly="{{_readonly}}"
1616
?required="{{required}}"
1717
.value="{{value}}"
18-
placeholder="{{inputPlaceholder}}"
18+
placeholder="{{placeholder}}"
1919
role="{{accInfo.input.role}}"
2020
aria-owns="{{accInfo.input.ariaOwns}}"
2121
aria-invalid="{{accInfo.input.ariaInvalid}}"

packages/main/src/Input.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ class Input extends UI5Element {
389389
if (isEnter(event)) {
390390
return this._handleEnter(event);
391391
}
392+
393+
this._keyDown = true;
394+
}
395+
396+
onkeyup() {
397+
this._keyDown = false;
392398
}
393399

394400
/* Event handling */
@@ -417,7 +423,7 @@ class Input extends UI5Element {
417423
}
418424
}
419425

420-
onfocusin() {
426+
onfocusin(event) {
421427
this.focused = true; // invalidating property
422428
this.previousValue = this.value;
423429
}
@@ -437,7 +443,14 @@ class Input extends UI5Element {
437443
event.stopImmediatePropagation();
438444
}
439445

440-
this.fireEventByAction(this.ACTION_USER_INPUT);
446+
/* skip calling change event when an input with a placeholder is focused on IE
447+
- value of the host and the internal input should be differnt in case of actual input
448+
- input is called when a key is pressed => keyup should not be called yet
449+
*/
450+
const skipFiring = (this.getInputDOMRef().value === this.value) && isIE() && !this._keyDown && this.placeholder;
451+
452+
!skipFiring && this.fireEventByAction(this.ACTION_USER_INPUT);
453+
441454
this.hasSuggestionItemSelected = false;
442455

443456
if (this.Suggestions) {
@@ -562,12 +575,6 @@ class Input extends UI5Element {
562575
};
563576
}
564577

565-
get inputPlaceholder() {
566-
// We don`t support placeholder for IE,
567-
// because IE fires input events, when placeholder exists, leading to functional degredations.
568-
return isIE() ? "" : this.placeholder;
569-
}
570-
571578
get _readonly() {
572579
return this.readonly && !this.disabled;
573580
}

0 commit comments

Comments
 (0)