Selaa lähdekoodia

InputTextView should update #isEmpty on DOM change event.

Aleksander Nowodzinski 5 vuotta sitten
vanhempi
commit
baaac13161

+ 2 - 1
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -125,7 +125,8 @@ export default class InputTextView extends View {
 				'aria-describedby': bind.to( 'ariaDescribedById' )
 			},
 			on: {
-				input: bind.to( 'input' )
+				input: bind.to( 'input' ),
+				change: bind.to( this._updateIsEmpty.bind( this ) )
 			}
 		} );
 

+ 14 - 0
packages/ckeditor5-ui/tests/inputtext/inputtextview.js

@@ -173,6 +173,20 @@ describe( 'InputTextView', () => {
 				sinon.assert.calledOnce( spy );
 			} );
 		} );
+
+		describe( 'change event', () => {
+			it( 'should trigger update of the #isEmpty property', () => {
+				view.element.value = 'foo';
+				view.element.dispatchEvent( new Event( 'change' ) );
+
+				expect( view.isEmpty ).to.be.false;
+
+				view.element.value = '';
+				view.element.dispatchEvent( new Event( 'change' ) );
+
+				expect( view.isEmpty ).to.be.true;
+			} );
+		} );
 	} );
 
 	describe( 'render()', () => {