Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 0867cb3

Browse files
committed
clean settings data when unset
1 parent ea4366a commit 0867cb3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/packages/block/block/context/block-entry.context.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,23 @@ export abstract class UmbBlockEntryContext<
191191
this.#observeBlockTypeLabel();
192192
});
193193

194+
// Correct settings data, accordingly to configuration of the BlockType: [NL]
194195
this.observe(
195196
observeMultiple([this.settingsElementTypeKey, this.settingsDataContentTypeKey]),
196197
([settingsElementTypeKey, settingsDataContentTypeKey]) => {
198+
// Notice the values are only undefined while we are missing the source of these observables. [NL]
197199
if (settingsElementTypeKey === undefined || settingsDataContentTypeKey === undefined) return;
198-
if (settingsElementTypeKey !== null && settingsElementTypeKey !== settingsDataContentTypeKey) {
199-
// Update the settings model with latest elementTypeKey, so data is up to date with configuration: [NL]
200-
const currentSettings = this.#settings.getValue();
201-
if (currentSettings) {
202-
this._manager?.setOneSettings({ ...currentSettings, contentTypeKey: settingsElementTypeKey });
200+
// Is there a difference between configuration and actual data udi:
201+
if (settingsElementTypeKey !== settingsDataContentTypeKey) {
202+
// We need to update our udi for the settings data [NL]
203+
if (settingsElementTypeKey != null) {
204+
// Update the settings model with latest elementTypeKey, so data is up to date with configuration: [NL]
205+
const currentSettings = this.#settings.getValue();
206+
if (currentSettings) {
207+
this._manager?.setOneSettings({ ...currentSettings, contentTypeKey: settingsElementTypeKey });
208+
}
203209
}
210+
// We do not need to remove the settings if configuration is gone, cause another observation handles this. [NL]
204211
}
205212
},
206213
);

0 commit comments

Comments
 (0)