Skip to content

Commit 048572d

Browse files
committed
fixes to coderabbit's qa, prevent previews from having focus
1 parent 8966428 commit 048572d

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/components/design-library-list/design-library-list-item.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ const DesignLibraryListItem = memo( props => {
9494
tabIndex: 0,
9595
role: 'button',
9696
onClick: onClickHost,
97+
onKeyDown: e => {
98+
if ( e.key === 'Enter' || e.key === ' ' ) {
99+
e.preventDefault()
100+
onClickHost( e )
101+
}
102+
},
97103
}
98104

99105
return (

src/components/design-library-list/design-preview.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export const DesignPreview = ( {
9090

9191
setIsLoading( true )
9292

93+
// Prevent interaction and focus within the preview content
94+
wrapper.setAttribute( 'inert', '' )
95+
9396
const ric = window.requestIdleCallback ? ( cb => window.requestIdleCallback( cb, { timeout: 5000 } ) )
9497
: ( cb => setTimeout( cb, designIndex * 20 ) )
9598
const sanitizedHTML = safeHTML( blocks )

src/components/design-library-list/editor.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@
6767
right: 0;
6868
display: flex;
6969
gap: 24px;
70+
visibility: hidden;
7071

7172
.ugb-button-component {
7273
width: 100%;
7374
justify-content: center;
75+
pointer-events: none;
7476
}
7577
}
7678
&:hover {
@@ -81,8 +83,10 @@
8183
}
8284

8385
.stk-block-design__edit-btn-container {
86+
visibility: visible;
8487
opacity: 1;
8588
transition-delay: 1s;
89+
pointer-events: initial;
8690
}
8791
}
8892

src/welcome/import-export/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './design-library'
44
/**
55
* WordPress dependencies
66
*/
7-
import { __ } from '@wordpress/i18n'
7+
import { __, sprintf } from '@wordpress/i18n'
88
import {
99
Button, Modal, Snackbar, TabPanel,
1010
} from '@wordpress/components'
@@ -62,20 +62,28 @@ const ImportSettings = ( {
6262
}, importedSettings, settings )
6363
}, [ importedSettings ] )
6464

65-
const handleImport = () => {
65+
const handleImport = async () => {
6666
if ( ! ( 'settings' in importedSettings ) ) {
6767
onClose()
6868
return
6969
}
7070

7171
if ( Object.keys( errors ).length ) {
7272
setNotice( __( 'Failed to import settings.', i18n ) )
73+
// eslint-disable-next-line no-console
74+
console.error( sprintf( __( 'Stackable: Import error - %s', i18n ), Object.values( errors ).join( '\n' ) ) )
7375
} else if ( Object.keys( settingsToSave ).length === 0 ) {
7476
setNotice( __( 'No settings imported.', i18n ) )
7577
} else {
7678
const model = new models.Settings( settingsToSave )
77-
model.save()
78-
setNotice( __( 'Settings imported successfully.', i18n ) )
79+
try {
80+
await model.save()
81+
setNotice( __( 'Settings imported successfully.', i18n ) )
82+
} catch ( e ) {
83+
setNotice( __( 'Failed to import settings.', i18n ) )
84+
// eslint-disable-next-line no-console
85+
console.error( sprintf( __( 'Stackable: Import error - %s', i18n ), e ) )
86+
}
7987
}
8088

8189
onClose()

0 commit comments

Comments
 (0)