Skip to content

Commit

Permalink
fix: handle wizard loading on wizard tab
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe committed Nov 26, 2024
1 parent 10a45f4 commit 136b27e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/wizards/types/hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type WizardData = {
// Define the type for the selector's return value
type WizardSelector = {
getWizardData: ( slug: string ) => WizardData;
isLoading: () => boolean;
};

/**
Expand Down
17 changes: 16 additions & 1 deletion src/wizards/wizards-tab.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* WordPress dependencies.
*/
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies.
*/
import { WIZARD_STORE_NAMESPACE } from '../components/src/wizard/store';

/**
* Wizards Tab component.
*/
Expand All @@ -15,11 +25,16 @@ function WizardsTab( {
className?: string;
description?: React.ReactNode;
} ) {
const isWizardLoading = useSelect(
( select: ( namespace: string ) => WizardSelector ) =>
select( WIZARD_STORE_NAMESPACE ).isLoading(),
[]
);
const className = props.className || '';
return (
<div
className={ `${
isFetching ? 'is-fetching ' : ''
isWizardLoading || isFetching ? 'is-fetching ' : ''
}${ className } newspack-wizard__sections` }
>
<h1>{ title }</h1>
Expand Down

0 comments on commit 136b27e

Please sign in to comment.