Fix iframe remounting on routify changes
This commit is contained in:
parent
96c2163a47
commit
3b9c22f313
|
@ -3,8 +3,6 @@
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import { store, selectedScreen, currentAsset } from "builderStore"
|
import { store, selectedScreen, currentAsset } from "builderStore"
|
||||||
import iframeTemplate from "./iframeTemplate"
|
import iframeTemplate from "./iframeTemplate"
|
||||||
import { Screen } from "builderStore/store/screenTemplates/utils/Screen"
|
|
||||||
import { FrontendTypes } from "constants"
|
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
import {
|
import {
|
||||||
ProgressCircle,
|
ProgressCircle,
|
||||||
|
@ -24,17 +22,8 @@
|
||||||
let loading = true
|
let loading = true
|
||||||
let error
|
let error
|
||||||
|
|
||||||
// Create screen slot placeholder for use when a page is selected rather
|
|
||||||
// than a screen
|
|
||||||
const screenPlaceholder = new Screen()
|
|
||||||
.name("Screen Placeholder")
|
|
||||||
.route("*")
|
|
||||||
.component("@budibase/standard-components/screenslot")
|
|
||||||
.instanceName("Content Placeholder")
|
|
||||||
.json()
|
|
||||||
|
|
||||||
// Messages that can be sent from the iframe preview to the builder
|
// Messages that can be sent from the iframe preview to the builder
|
||||||
// Budibase events are and initalisation events
|
// Budibase events are and initialisation events
|
||||||
const MessageTypes = {
|
const MessageTypes = {
|
||||||
READY: "ready",
|
READY: "ready",
|
||||||
ERROR: "error",
|
ERROR: "error",
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { IconSideNav, IconSideNavItem } from "@budibase/bbui"
|
import { IconSideNav, IconSideNavItem } from "@budibase/bbui"
|
||||||
import { goto, isActive } from "@roxi/routify"
|
import { goto, isActive } from "@roxi/routify"
|
||||||
|
import AppPanel from "./_components/AppPanel.svelte"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="design">
|
<div class="design">
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<slot />
|
<slot />
|
||||||
|
<AppPanel />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -64,4 +66,17 @@
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
This is hacky, yes, but it's the only way to prevent routify from
|
||||||
|
remounting the iframe on route changes.
|
||||||
|
*/
|
||||||
|
.content :global(> *:last-child) {
|
||||||
|
order: 1;
|
||||||
|
}
|
||||||
|
.content :global(> *:first-child) {
|
||||||
|
order: 0;
|
||||||
|
}
|
||||||
|
.content :global(> *:nth-child(2)) {
|
||||||
|
order: 2;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import AppPanel from "components/design/AppPanel/AppPanel.svelte"
|
|
||||||
import ComponentNavigationPanel from "./_components/ComponentNavigationPanel.svelte"
|
import ComponentNavigationPanel from "./_components/ComponentNavigationPanel.svelte"
|
||||||
import ComponentSettingsPanel from "./_components/ComponentSettingsPanel.svelte"
|
import ComponentSettingsPanel from "./_components/ComponentSettingsPanel.svelte"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ComponentNavigationPanel />
|
<ComponentNavigationPanel />
|
||||||
<AppPanel />
|
|
||||||
<ComponentSettingsPanel />
|
<ComponentSettingsPanel />
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import ComponentListPanel from "./_components/ComponentListPanel.svelte"
|
import ComponentListPanel from "./_components/ComponentListPanel.svelte"
|
||||||
import AppPanel from "components/design/AppPanel/AppPanel.svelte"
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ComponentListPanel />
|
<ComponentListPanel />
|
||||||
<AppPanel />
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
import { syncURLToState } from "helpers/urlStateSync"
|
import { syncURLToState } from "helpers/urlStateSync"
|
||||||
import { goto, params, redirect } from "@roxi/routify"
|
import { goto, params, redirect } from "@roxi/routify"
|
||||||
import AppPanel from "components/design/AppPanel/AppPanel.svelte"
|
|
||||||
import ScreenNavigationPanel from "./_components/ScreenNavigationPanel.svelte"
|
import ScreenNavigationPanel from "./_components/ScreenNavigationPanel.svelte"
|
||||||
import ScreenSettingsPanel from "./_components/ScreenSettingsPanel.svelte"
|
import ScreenSettingsPanel from "./_components/ScreenSettingsPanel.svelte"
|
||||||
|
|
||||||
|
@ -27,5 +26,4 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ScreenNavigationPanel />
|
<ScreenNavigationPanel />
|
||||||
<AppPanel />
|
|
||||||
<ScreenSettingsPanel />
|
<ScreenSettingsPanel />
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const setScreenSetting = (setting, value) => {
|
const setScreenSetting = (setting, value) => {
|
||||||
const { name, parser, validate } = setting
|
const { key, parser, validate } = setting
|
||||||
|
|
||||||
// Parse value if required
|
// Parse value if required
|
||||||
if (parser) {
|
if (parser) {
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
const error = validate(value)
|
const error = validate(value)
|
||||||
errors = {
|
errors = {
|
||||||
...errors,
|
...errors,
|
||||||
[name]: error,
|
[key]: error,
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
return
|
return
|
||||||
|
@ -56,13 +56,13 @@
|
||||||
} else {
|
} else {
|
||||||
errors = {
|
errors = {
|
||||||
...errors,
|
...errors,
|
||||||
[name]: null,
|
[key]: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update screen object in store
|
// Update screen object in store
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
setWith(get(selectedScreen), name.split("."), value, Object)
|
setWith(get(selectedScreen), key.split("."), value, Object)
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import NavigationPanel from "components/design/NavigationPanel/NavigationPanel.svelte"
|
import NavigationPanel from "components/design/NavigationPanel/NavigationPanel.svelte"
|
||||||
import { Body, Layout } from "@budibase/bbui"
|
import { Body, Layout } from "@budibase/bbui"
|
||||||
import AppPanel from "components/design/AppPanel/AppPanel.svelte"
|
|
||||||
import ThemeEditor from "./_components/ThemeEditor.svelte"
|
import ThemeEditor from "./_components/ThemeEditor.svelte"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -11,5 +10,3 @@
|
||||||
<ThemeEditor />
|
<ThemeEditor />
|
||||||
</Layout>
|
</Layout>
|
||||||
</NavigationPanel>
|
</NavigationPanel>
|
||||||
|
|
||||||
<AppPanel />
|
|
||||||
|
|
Loading…
Reference in New Issue