From 1508a5dc3bb62dd8b1bfd2e8496c808fbf3361ea Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 20 Oct 2022 08:43:33 +0100 Subject: [PATCH] Update how grid DND styles are applied to remove flashing --- packages/client/manifest.json | 7 ++++- .../client/src/components/Component.svelte | 7 +++++ .../components/preview/GridDNDHandler.svelte | 30 +++++++++---------- packages/client/src/stores/components.js | 9 ++++++ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 94b3ac36be..39f4ec9aac 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -4574,7 +4574,12 @@ "size" ], "illegalChildren": ["grid", "section"], - "allowedDirectChildren": [""] + "allowedDirectChildren": [""], + "size": { + "width": 800, + "height": 400 + }, + "showEmptyState": false }, "formblock": { "name": "Form Block", diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index d9264f93bf..439863fb2b 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -91,6 +91,10 @@ let settingsDefinitionMap let missingRequiredSettings = false + // Temporary styles which can be added in the app preview for things like DND. + // We clear these whenever a new instance is received. + let ephemeralStyles + // Set up initial state for each new component instance $: initialise(instance) @@ -181,6 +185,7 @@ normal: { ...instance._styles?.normal, ...additionalStyles, + ...ephemeralStyles, }, custom: customCSS, id, @@ -214,6 +219,7 @@ return } else { lastInstanceKey = instanceKey + ephemeralStyles = null } // Pull definition and constructor @@ -515,6 +521,7 @@ getRawSettings: () => ({ ...staticSettings, ...dynamicSettings }), getDataContext: () => get(context), reload: () => initialise(instance, true), + setEphemeralStyles: styles => (ephemeralStyles = styles), }) } }) diff --git a/packages/client/src/components/preview/GridDNDHandler.svelte b/packages/client/src/components/preview/GridDNDHandler.svelte index 1cb4f92da6..7094e5c507 100644 --- a/packages/client/src/components/preview/GridDNDHandler.svelte +++ b/packages/client/src/components/preview/GridDNDHandler.svelte @@ -1,14 +1,18 @@