Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Added TextInputView#isReadOnly state. #267

Merged
merged 5 commits into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/inputtext/inputtextview.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export default class InputTextView extends View {
*/
this.set( 'placeholder' );

/**
* Controls whether the input view is in read-only mode.
*
* @observable
* @member {Boolean} #isReadOnly
*/
this.set( 'isReadOnly', false );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't LabeledInputView also implement it? I think the state may also affect the label/entire field in general (like changing the color of the label). readonly is common for all inputs so I guess LabeledInputView should interface it for all inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I added only a state. I didn't add any CSS class reflecting this state.


const bind = this.bindTemplate;

this.template = new Template( {
Expand All @@ -57,7 +65,8 @@ export default class InputTextView extends View {
'ck-input-text'
],
id: bind.to( 'id' ),
placeholder: bind.to( 'placeholder' )
placeholder: bind.to( 'placeholder' ),
readonly: bind.to( 'isReadOnly' )
}
} );

Expand Down
10 changes: 10 additions & 0 deletions tests/inputtext/inputtextview.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ describe( 'InputTextView', () => {
expect( view.element.placeholder ).to.equal( 'baz' );
} );
} );

describe( 'isReadOnly', () => {
it( 'should react on view#isReadOnly', () => {
expect( view.element.readOnly ).to.false;

view.isReadOnly = true;

expect( view.element.readOnly ).to.true;
} );
} );
} );

describe( 'select()', () => {
Expand Down