fix functionality based on tests
This commit is contained in:
@@ -57,7 +57,8 @@ export class UmbSelectionManager extends UmbBaseController {
|
|||||||
public setSelection(value: Array<string | null>) {
|
public setSelection(value: Array<string | null>) {
|
||||||
if (this.getSelectable() === false) return;
|
if (this.getSelectable() === false) return;
|
||||||
if (value === undefined) throw new Error('Value cannot be undefined');
|
if (value === undefined) throw new Error('Value cannot be undefined');
|
||||||
this.#selection.next(value);
|
const newSelection = this.getMultiple() ? value : [value[0]];
|
||||||
|
this.#selection.next(newSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,6 +96,7 @@ export class UmbSelectionManager extends UmbBaseController {
|
|||||||
*/
|
*/
|
||||||
public select(unique: string | null) {
|
public select(unique: string | null) {
|
||||||
if (this.getSelectable() === false) return;
|
if (this.getSelectable() === false) return;
|
||||||
|
if (this.isSelected(unique)) return;
|
||||||
const newSelection = this.getMultiple() ? [...this.getSelection(), unique] : [unique];
|
const newSelection = this.getMultiple() ? [...this.getSelection(), unique] : [unique];
|
||||||
this.#selection.next(newSelection);
|
this.#selection.next(newSelection);
|
||||||
this._host.getHostElement().dispatchEvent(new UmbSelectionChangeEvent());
|
this._host.getHostElement().dispatchEvent(new UmbSelectionChangeEvent());
|
||||||
@@ -127,6 +129,7 @@ export class UmbSelectionManager extends UmbBaseController {
|
|||||||
* @memberof UmbSelectionManager
|
* @memberof UmbSelectionManager
|
||||||
*/
|
*/
|
||||||
public clearSelection() {
|
public clearSelection() {
|
||||||
|
if (this.getSelectable() === false) return;
|
||||||
this.#selection.next([]);
|
this.#selection.next([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user