From 87305f3c9d09ec2b08f4e70bfd3a02ee3ae2219d Mon Sep 17 00:00:00 2001 From: Illia Sheremetov Date: Wed, 9 Aug 2023 14:59:20 +0200 Subject: [PATCH] Fix (ckbox): tiny improvements --- packages/ckeditor5-ckbox/src/ckboxcommand.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/ckeditor5-ckbox/src/ckboxcommand.ts b/packages/ckeditor5-ckbox/src/ckboxcommand.ts index adbb396a953..dc958c0d80a 100644 --- a/packages/ckeditor5-ckbox/src/ckboxcommand.ts +++ b/packages/ckeditor5-ckbox/src/ckboxcommand.ts @@ -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' ); @@ -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 ); }