Skip to content

Commit d784f82

Browse files
authoredMar 20, 2024··
fix(structure): use correct loading messages while resolving panes (#6093)
1 parent abfc5d2 commit d784f82

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {Card, Stack, Text} from '@sanity/ui'
2+
3+
import {PaneLayout} from '../components'
4+
import {LoadingPane} from '../panes'
5+
6+
export default function LoadingPaneStory() {
7+
return (
8+
<Stack space={3}>
9+
<Card padding={4} tone="positive">
10+
<Text align="center">
11+
Note: This is <em>intentionally</em> not resolving. We're testing the loading pane!
12+
</Text>
13+
</Card>
14+
<PaneLayout height="fill">
15+
<LoadingPane paneKey="loading" />
16+
</PaneLayout>
17+
</Stack>
18+
)
19+
}

‎packages/sanity/src/structure/__workshop__/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ export default defineScope({
1515
title: 'Document state',
1616
component: lazy(() => import('./DocumentStateStory')),
1717
},
18+
{
19+
name: 'loading-pane',
20+
title: 'Loading pane',
21+
component: lazy(() => import('./LoadingPaneStory')),
22+
},
1823
],
1924
})

‎packages/sanity/src/structure/panes/loading/LoadingPane.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export const LoadingPane = memo((props: LoadingPaneProps) => {
6161

6262
const [currentMessage, setCurrentMessage] = useState<string | null>(() => {
6363
if (typeof resolvedMessage === 'string') return resolvedMessage
64-
return DEFAULT_MESSAGE_KEY
64+
return t(DEFAULT_MESSAGE_KEY)
6565
})
6666

6767
useEffect(() => {
6868
if (typeof resolvedMessage !== 'object') return undefined
69-
if (typeof resolvedMessage.subscribe === 'function') return undefined
69+
if (typeof resolvedMessage.subscribe !== 'function') return undefined
7070

7171
const sub = resolvedMessage.subscribe((message) => {
7272
setCurrentMessage('messageKey' in message ? t(message.messageKey) : message.message)

0 commit comments

Comments
 (0)
Please sign in to comment.