diff --git a/src/Umbraco.Web.UI.Client/src/shared/utils/selection-manager/selection.manager.ts b/src/Umbraco.Web.UI.Client/src/shared/utils/selection-manager/selection.manager.ts index b71f1a66d6..ff63bfd93d 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/utils/selection-manager/selection.manager.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/utils/selection-manager/selection.manager.ts @@ -57,7 +57,7 @@ export class UmbSelectionManager extends UmbBaseController { public setSelection(value: Array) { if (this.getSelectable() === false) return; if (value === undefined) throw new Error('Value cannot be undefined'); - const newSelection = this.getMultiple() ? value : [value[0]]; + const newSelection = this.getMultiple() ? value : value.length > 0 ? [value[0]] : value; this.#selection.next(newSelection); } @@ -78,7 +78,7 @@ export class UmbSelectionManager extends UmbBaseController { public setMultiple(value: boolean) { this.#multiple.next(value); - /* If multiple is set to false, and the current selection is more than one, + /* If multiple is set to false, and the current selection is more than one, then we need to set the selection to the first item. */ if (value === false && this.getSelection().length > 1) { this.setSelection([this.getSelection()[0]]);