@@ -70,6 +70,13 @@ export const Content = () => {
70
70
} ;
71
71
} ) ;
72
72
73
+ // Add this new state to cache display values
74
+ const [ cachedDisplayData , setCachedDisplayData ] = useState ( {
75
+ displayName : '' ,
76
+ path : '' ,
77
+ } ) ;
78
+
79
+ // Update this useEffect to also cache display data when data loads
73
80
useEffect ( ( ) => {
74
81
if ( prevContentIdRef . current && prevContentIdRef . current !== selectedContentId ) {
75
82
clearCachedVersionSelector ( prevContentIdRef . current ) ;
@@ -81,10 +88,18 @@ export const Content = () => {
81
88
versions : data . versions ,
82
89
isOpen : prev . isOpen ,
83
90
} ) ) ;
91
+
92
+ // Cache display data when it's available
93
+ if ( data . json ?. displayName || data . json ?. _path ) {
94
+ setCachedDisplayData ( {
95
+ displayName : data . json . displayName || '' ,
96
+ path : data . json . _path || '' ,
97
+ } ) ;
98
+ }
84
99
}
85
100
86
101
prevContentIdRef . current = selectedContentId ;
87
- } , [ selectedContentId , data ?. versions ] ) ;
102
+ } , [ selectedContentId , data ?. versions , data ?. json ] ) ;
88
103
89
104
useEffect ( ( ) => {
90
105
setSelectedView ( getDefaultView ( isWebpage , hasAttachment ) ) ;
@@ -114,6 +129,15 @@ export const Content = () => {
114
129
return 'Laster...' ;
115
130
} ;
116
131
132
+ // Add helper functions to get title and URL with fallbacks
133
+ const getDisplayName = ( ) => {
134
+ return data ?. json . displayName || cachedDisplayData . displayName || 'Laster...' ;
135
+ } ;
136
+
137
+ const getPath = ( ) => {
138
+ return data ?. json . _path || cachedDisplayData . path || '' ;
139
+ } ;
140
+
117
141
if ( ! selectedContentId ) {
118
142
return < EmptyState /> ;
119
143
}
@@ -195,10 +219,10 @@ export const Content = () => {
195
219
196
220
< div className = { style . titleAndUrl } >
197
221
< Heading size = { 'medium' } level = { '2' } >
198
- { data ?. json . displayName ?? '' }
222
+ { getDisplayName ( ) }
199
223
</ Heading >
200
224
< div className = { style . url } >
201
- < Detail > { data ?. json . _path ?? '' } </ Detail >
225
+ < Detail > { getPath ( ) } </ Detail >
202
226
</ div >
203
227
</ div >
204
228
</ div >
0 commit comments