@@ -3,6 +3,7 @@ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
3
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
4
4
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
5
5
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
6
+ import { isIE } from "@ui5/webcomponents-core/dist/sap/ui/Device.js" ;
6
7
import TextAreaTemplate from "./generated/templates/TextAreaTemplate.lit.js" ;
7
8
8
9
import { TEXTAREA_CHARACTERS_LEFT , TEXTAREA_CHARACTERS_EXCEEDED } from "./generated/i18n/i18n-defaults.js" ;
@@ -189,9 +190,6 @@ const metadata = {
189
190
type : String ,
190
191
noAttribute : true ,
191
192
} ,
192
- _listeners : {
193
- type : Object ,
194
- } ,
195
193
} ,
196
194
events : /** @lends sap.ui.webcomponents.main.TextArea.prototype */ {
197
195
/**
@@ -201,6 +199,16 @@ const metadata = {
201
199
* @public
202
200
*/
203
201
change : { } ,
202
+
203
+ /**
204
+ * Fired when the value of the <code>ui5-textarea</code> changes at each keystroke or when
205
+ * something is pasted.
206
+ *
207
+ * @event
208
+ * @since 1.0.0-rc.5
209
+ * @public
210
+ */
211
+ input : { } ,
204
212
} ,
205
213
_eventHandlersByConvention : true ,
206
214
} ;
@@ -250,10 +258,6 @@ class TextArea extends UI5Element {
250
258
super ( ) ;
251
259
252
260
this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
253
-
254
- this . _listeners = {
255
- change : this . _handleChange . bind ( this ) ,
256
- } ;
257
261
}
258
262
259
263
onBeforeRendering ( ) {
@@ -295,6 +299,14 @@ class TextArea extends UI5Element {
295
299
this . value = inputValue ;
296
300
}
297
301
302
+ onkeydown ( ) {
303
+ this . _keyDown = true ;
304
+ }
305
+
306
+ onkeyup ( ) {
307
+ this . _keyDown = false ;
308
+ }
309
+
298
310
onfocusin ( ) {
299
311
this . focused = true ;
300
312
}
@@ -307,6 +319,30 @@ class TextArea extends UI5Element {
307
319
this . fireEvent ( "change" , { } ) ;
308
320
}
309
321
322
+ _handleInput ( event ) {
323
+ const nativeTextarea = this . getInputDomRef ( ) ;
324
+
325
+ /* skip calling change event when an textarea with a placeholder is focused on IE
326
+ - value of the host and the internal textarea should be different in case of actual input
327
+ - input is called when a key is pressed => keyup should not be called yet
328
+ */
329
+ const skipFiring = ( this . getInputDomRef ( ) . value === this . value ) && isIE ( ) && ! this . _keyDown && ! ! this . placeholder ;
330
+ if ( event . target === nativeTextarea ) {
331
+ // stop the native event, as the semantic "input" would be fired.
332
+ event . stopImmediatePropagation ( ) ;
333
+ }
334
+
335
+ if ( skipFiring ) {
336
+ return ;
337
+ }
338
+
339
+ this . value = nativeTextarea . value ;
340
+ this . fireEvent ( "input" , { } ) ;
341
+
342
+ // Angular two way data binding
343
+ this . fireEvent ( "value-changed" ) ;
344
+ }
345
+
310
346
_tokenizeText ( value ) {
311
347
const tokenizedText = value . replace ( / & / gm, "&" ) . replace ( / " / gm, """ ) . replace ( / " / gm, "'" ) . replace ( / < / gm, "<" )
312
348
. replace ( / > / gm, ">" )
0 commit comments