Skip to content

Commit

Permalink
Fix (ckbox): tiny improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-stv committed Aug 9, 2023
1 parent 64f5d88 commit 87305f3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/ckeditor5-ckbox/src/ckboxcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function focusCKBoxItem( limiter: number ): void {
return;
}

const ckboxGallery = document.getElementsByClassName( 'ckbox-gallery' )[ 0 ];
const ckboxGalleryFirstItem = document.querySelector( '.ckbox-gallery .ckbox-gallery-item' );
// In case there is no items, "upload button" will be appeared in "div" with
// classname ".ckbox-empty-view".
const uploadButton = document.querySelector( '.ckbox-empty-view .ckbox-btn' );
Expand All @@ -415,18 +415,8 @@ function focusCKBoxItem( limiter: number ): void {
return;
}

if ( !ckboxGallery ) {
focusCKBoxItem( limiter - 1 );
return;
}

const firstItem = ckboxGallery.children[ 0 ];

if ( firstItem &&
firstItem.className === 'ckbox-gallery-item' &&
firstItem instanceof HTMLElement
) {
firstItem.focus();
if ( ckboxGalleryFirstItem && ckboxGalleryFirstItem instanceof HTMLElement ) {
ckboxGalleryFirstItem.focus();
} else {
focusCKBoxItem( limiter - 1 );
}
Expand Down

0 comments on commit 87305f3

Please sign in to comment.