Skip to content

Commit

Permalink
KAD-3202 Prevent flash of chooser on load
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Aug 9, 2024
1 parent bfb61d1 commit 6c88587
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/blocks/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function Edit(props) {
const { attributes, setAttributes, isSelected, clientId } = props;

const { id, uniqueID, templateKey } = attributes;
const [hasStartedLoading, setHasStartedLoading] = useState(false);

// Since we're not in the EntityProvider yet, we need to provide a post id.
// 'id' and 'meta' will be undefined untill the actual post is chosen / loaded
Expand Down Expand Up @@ -201,10 +202,15 @@ export function Edit(props) {
}
}, [isSelected]);

if (!hasStartedLoading && isLoading) {
setHasStartedLoading(true);
}

return (
<div {...blockProps}>
{/* No navigation selected or selected navigation was deleted from the site, display chooser */}
{((id === 0 && !templateKey) || (undefined === postExists && !isLoading)) && (
{((id === 0 && !templateKey) ||
(undefined === postExists && hasStartedLoading && !isLoading && post !== null)) && (
<Chooser
id={id}
postExists={postExists}
Expand Down

0 comments on commit 6c88587

Please sign in to comment.