Skip to content

Commit 52b952a

Browse files
committed
fix(url-state): hold first paint while a custom-block deep link can still resolve
A valid ?custom-block-id= no longer flashes the list while the blocks query is pending; a dead id still falls back to the list once loaded.
1 parent 03f1641 commit 52b952a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/sim/ee/custom-blocks/components/custom-blocks.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function CustomBlocks() {
2929
const canAdmin = canMutateWorkspaceSettingsSection('custom-blocks', workspacePermissions)
3030

3131
const { data: canManage = false, isLoading } = useCanPublishCustomBlock(workspaceId)
32-
const { data: blocks = [] } = useCustomBlocks(workspaceId)
32+
const { data: blocks = [], isPending: blocksPending } = useCustomBlocks(workspaceId)
3333
const { data: workspaces = [] } = useWorkspacesQuery()
3434

3535
/** Publishing requires admin on a source workspace; viewing remains workspace-scoped. */
@@ -63,7 +63,12 @@ export function CustomBlocks() {
6363
/** Open the detail only once the deep-linked id resolves to a loaded block. */
6464
const selectedBlock = selectedBlockId ? blocks.find((b) => b.id === selectedBlockId) : undefined
6565

66-
if (isLoading) return null
66+
/**
67+
* Hold the first paint while a deep-linked id could still resolve, so a
68+
* valid link never flashes the list before jumping to the detail (a dead id
69+
* falls back to the list once the blocks load).
70+
*/
71+
if (isLoading || (selectedBlockId && canAdmin && blocksPending)) return null
6772

6873
if (!canManage) {
6974
return (

0 commit comments

Comments
 (0)