@@ -233,20 +233,24 @@ export default {
233233 return
234234 }
235235
236- // Remove the not existing keys because the related fields might have been
237- // deleted in the meantime, and so we're keeping the local storage clean.
236+ // Remove entries for fields that no longer exist in the table, keeping
237+ // IndexedDB clean. Uses allFields (the actual table fields) instead of
238+ // fieldOptions (grid view API response) which may be empty or incomplete.
239+ const existingFieldIds = new Set (
240+ this .allFields .map ((field ) => field .id .toString ())
241+ )
238242 value = Object .fromEntries (
239- Object .entries (value).filter ((key ) => {
240- return Object .prototype .hasOwnProperty .call (this .fieldOptions , key[0 ])
241- })
243+ Object .entries (value).filter (([key ]) => existingFieldIds .has (key))
242244 )
243245
244246 try {
247+ // clone() strips Vue 3 Proxy wrappers so the value can be stored via
248+ // IndexedDB's structured clone algorithm.
245249 await setData (
246250 databaseName,
247251 storeName,
248252 this .persistentFieldOptionsKey ,
249- value
253+ clone ( value)
250254 )
251255 } catch (error) {
252256 /* empty */
@@ -267,6 +271,17 @@ export default {
267271
268272 await this .orderFieldsByFirstGridViewFieldOptions (this .tableId )
269273
274+ if (this .persistentFieldOptionsKey ) {
275+ try {
276+ const override = await getData (
277+ databaseName,
278+ storeName,
279+ this .persistentFieldOptionsKey
280+ )
281+ this .fieldOptionsOverride = override || {}
282+ } catch (error) {}
283+ }
284+
270285 // Because the page data depends on having some initial metadata we mark the state
271286 // as loaded after that. Only a loading animation is shown if there isn't any
272287 // data.
@@ -338,15 +353,6 @@ export default {
338353 data: { field_options: fieldOptions },
339354 } = await ViewService (this .$client ).fetchFieldOptions (views[0 ].id )
340355 this .fieldOptions = fieldOptions
341-
342- if (this .persistentFieldOptionsKey ) {
343- const override = await getData (
344- databaseName,
345- storeName,
346- this .persistentFieldOptionsKey
347- )
348- this .fieldOptionsOverride = override || {}
349- }
350356 } catch (error) {
351357 notifyIf (error, ' view' )
352358 }
0 commit comments