Преглед на файлове

Implemented LabeledInputView#focus() and InputTextView#focus() methods.

Aleksander Nowodzinski преди 9 години
родител
ревизия
f784d016c0

+ 7 - 0
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -62,4 +62,11 @@ export default class InputTextView extends View {
 	select() {
 		this.element.select();
 	}
+
+	/**
+	 * Focuses the input.
+	 */
+	focus() {
+		this.element.focus();
+	}
 }

+ 7 - 0
packages/ckeditor5-ui/src/labeledinput/labeledinputview.js

@@ -109,4 +109,11 @@ export default class LabeledInputView extends View {
 	select() {
 		this.inputView.select();
 	}
+
+	/**
+	 * Focuses the input.
+	 */
+	focus() {
+		this.inputView.focus();
+	}
 }

+ 11 - 1
packages/ckeditor5-ui/tests/inputtext/inputtextview.js

@@ -58,7 +58,7 @@ describe( 'InputTextView', () => {
 		} );
 	} );
 
-	describe( 'select', () => {
+	describe( 'select()', () => {
 		it( 'should select input value', () => {
 			const selectSpy = sinon.spy( view.element, 'select' );
 
@@ -69,4 +69,14 @@ describe( 'InputTextView', () => {
 			selectSpy.restore();
 		} );
 	} );
+
+	describe( 'focus()', () => {
+		it( 'focuses the input in DOM', () => {
+			const spy = sinon.spy( view.element, 'focus' );
+
+			view.focus();
+
+			sinon.assert.calledOnce( spy );
+		} );
+	} );
 } );

+ 11 - 1
packages/ckeditor5-ui/tests/labeledinput/labeledinputview.js

@@ -60,7 +60,7 @@ describe( 'LabeledInputView', () => {
 		} );
 	} );
 
-	describe( 'select', () => {
+	describe( 'select()', () => {
 		it( 'should select input value', () => {
 			const spy = sinon.spy( view.inputView, 'select' );
 
@@ -69,4 +69,14 @@ describe( 'LabeledInputView', () => {
 			sinon.assert.calledOnce( spy );
 		} );
 	} );
+
+	describe( 'focus()', () => {
+		it( 'focuses the input in DOM', () => {
+			const spy = sinon.spy( view.inputView, 'focus' );
+
+			view.focus();
+
+			sinon.assert.calledOnce( spy );
+		} );
+	} );
 } );