File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/Ari
6
6
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
7
7
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
8
8
import { isIE } from "@ui5/webcomponents-base/dist/Device.js" ;
9
+ import { isEscape } from "@ui5/webcomponents-base/dist/Keys.js" ;
9
10
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
10
11
import Popover from "./Popover.js" ;
11
12
@@ -427,8 +428,16 @@ class TextArea extends UI5Element {
427
428
return this . getDomRef ( ) . querySelector ( "textarea" ) ;
428
429
}
429
430
430
- _onkeydown ( ) {
431
+ _onkeydown ( event ) {
431
432
this . _keyDown = true ;
433
+
434
+ if ( isEscape ( event ) ) {
435
+ const nativeTextArea = this . getInputDomRef ( ) ;
436
+
437
+ this . value = this . previousValue ;
438
+ nativeTextArea . value = this . value ;
439
+ this . fireEvent ( "input" ) ;
440
+ }
432
441
}
433
442
434
443
_onkeyup ( ) {
@@ -438,6 +447,7 @@ class TextArea extends UI5Element {
438
447
_onfocusin ( ) {
439
448
this . focused = true ;
440
449
this . _openValueStateMsgPopover = true ;
450
+ this . previousValue = this . getInputDomRef ( ) . value ;
441
451
}
442
452
443
453
_onfocusout ( ) {
Original file line number Diff line number Diff line change @@ -225,3 +225,27 @@ describe("when enabled", () => {
225
225
} ) ;
226
226
} ) ;
227
227
} ) ;
228
+
229
+ describe ( "Value update" , ( ) => {
230
+ before ( ( ) => {
231
+ browser . url ( `http://localhost:${ PORT } /test-resources/pages/TextArea.html` ) ;
232
+ } ) ;
233
+
234
+ it ( "Should revert the DOM value, when escape is pressed" , ( ) => {
235
+ const textarea = $ ( "#basic-textarea" ) ;
236
+
237
+ // act
238
+ textarea . click ( ) ;
239
+ textarea . keys ( "1" ) ;
240
+ textarea . keys ( "2" ) ;
241
+
242
+ // assert
243
+ assert . strictEqual ( textarea . getProperty ( "value" ) , "12" , "Value is updated" ) ;
244
+
245
+ // act
246
+ textarea . keys ( "Escape" ) ;
247
+
248
+ // assert
249
+ assert . strictEqual ( textarea . getProperty ( "value" ) , "" , "Value is reverted" ) ;
250
+ } ) ;
251
+ } ) ;
You can’t perform that action at this time.
0 commit comments