Skip to content

Commit

Permalink
Merge pull request #16025 from ckeditor/ck/6032
Browse files Browse the repository at this point in the history
Feature (ui): Added the `tabindex` DOM attribute support to the `InputBase` class.
  • Loading branch information
oleq authored Mar 18, 2024
2 parents 952cd75 + 0583f9d commit 5a39981
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit 5a39981

Please sign in to comment.