Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tabindex support to the InputBase class #16025

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions packages/ckeditor5-ui/src/input/inputbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export default abstract class InputBase<TElement extends HTMLInputElement | HTML
*/
declare public placeholder: string | undefined;

/**
* The `tabindex` attribute of the input.
*
* @observable
*/
declare public tabIndex: number | undefined;

/**
* The `aria-label` attribute of the input.
*
Expand Down Expand Up @@ -105,6 +112,7 @@ export default abstract class InputBase<TElement extends HTMLInputElement | HTML
this.set( 'value', undefined );
this.set( 'id', undefined );
this.set( 'placeholder', undefined );
this.set( 'tabIndex', undefined );
this.set( 'isReadOnly', false );
this.set( 'hasError', false );
this.set( 'ariaDescribedById', undefined );
Expand All @@ -129,6 +137,7 @@ export default abstract class InputBase<TElement extends HTMLInputElement | HTML
],
id: bind.to( 'id' ),
placeholder: bind.to( 'placeholder' ),
tabindex: bind.to( 'tabIndex' ),
readonly: bind.to( 'isReadOnly' ),
'aria-invalid': bind.if( 'hasError', true ),
'aria-describedby': bind.to( 'ariaDescribedById' ),
Expand Down
10 changes: 10 additions & 0 deletions packages/ckeditor5-ui/tests/input/inputbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ describe( 'InputBase', () => {
} );
} );

describe( 'tabIndex', () => {
it( 'should react on view#tabIndex', () => {
expect( view.element.getAttribute( 'tabIndex' ) ).to.be.null;

view.tabIndex = 123;

expect( view.element.getAttribute( 'tabIndex' ) ).to.equal( '123' );
} );
} );

describe( 'aria-label', () => {
it( 'should react on view#ariaLabel', () => {
expect( view.element.getAttribute( 'aria-label' ) ).to.be.null;
Expand Down