diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js
index 4d8e2a8134..3ef15c0d9e 100644
--- a/packages/builder/cypress/integration/createView.spec.js
+++ b/packages/builder/cypress/integration/createView.spec.js
@@ -21,6 +21,7 @@ context("Create a View", () => {
cy.get("input").type("Test View")
cy.contains("Save View").click()
})
+ cy.wait(1000)
cy.get(".table-title h1").contains("Test View")
cy.get("[data-cy=table-header]").then($headers => {
expect($headers).to.have.length(3)
diff --git a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
index 4e7f430a1c..2b6e775c9a 100644
--- a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
+++ b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
@@ -44,7 +44,7 @@
{/if}
- {#each Object.keys(table.views || {}) as viewName}
+ {#each Object.keys(table.views || {}) as viewName, idx (idx)}
{
+ select: async view => {
update(state => ({
...state,
selected: view,
@@ -29,18 +29,15 @@ export function createViewsStore() {
...json,
}
- update(state => {
- const viewTable = get(tables).list.find(
- table => table._id === view.tableId
- )
+ const viewTable = get(tables).list.find(
+ table => table._id === view.tableId
+ )
- if (view.originalName) delete viewTable.views[view.originalName]
- viewTable.views[view.name] = viewMeta
-
- state.tables = state.tables
- state.selectedView = viewMeta
- return state
- })
+ if (view.originalName) delete viewTable.views[view.originalName]
+ viewTable.views[view.name] = viewMeta
+ await tables.save(viewTable)
+
+ update(state => ({...state, selected: viewMeta}))
},
}
}