Comments: Addressed a range of edge cases and ux issues for references

Handles only display and handling references when they're in the active
tab, while handling proper removal when made not visible.
This commit is contained in:
Dan Brown
2025-05-01 16:33:42 +01:00
parent e7dcc2dcdf
commit 15c79c38db
3 changed files with 37 additions and 8 deletions

View File

@ -139,8 +139,8 @@ export class ComponentStore {
/**
* Get all the components of the given name.
*/
public get(name: string): Component[] {
return this.components[name] || [];
public get<T extends Component>(name: string): T[] {
return (this.components[name] || []) as T[];
}
/**
@ -150,4 +150,9 @@ export class ComponentStore {
const elComponents = this.elementComponentMap.get(element) || {};
return elComponents[name] || null;
}
public allWithinElement<T extends Component>(element: HTMLElement, name: string): T[] {
const components = this.get<T>(name);
return components.filter(c => element.contains(c.$el));
}
}