Skip to content

Commit

Permalink
fix: add missing section type to dashboard events (#8325) (#8326)
Browse files Browse the repository at this point in the history
* fix: add missing section type to dashboard events

* revert type for resize move changed event

Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
  • Loading branch information
vaadin-bot and sissbruecker authored Dec 11, 2024
1 parent fd8e68c commit 0bf0d91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/dashboard/src/vaadin-dashboard.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type DashboardRenderer<TItem extends DashboardItem> = (
* Fired when an item was moved
*/
export type DashboardItemMovedEvent<TItem extends DashboardItem> = CustomEvent<{
item: TItem;
item: TItem | DashboardSectionItem<TItem>;

items: Array<TItem | DashboardSectionItem<TItem>>;

Expand Down Expand Up @@ -97,15 +97,15 @@ export type DashboardItemRemovedEvent<TItem extends DashboardItem> = CustomEvent
* Fired when an item selected state changed
*/
export type DashboardItemSelectedChangedEvent<TItem extends DashboardItem> = CustomEvent<{
item: TItem;
item: TItem | DashboardSectionItem<TItem>;
value: boolean;
}>;

/**
* Fired when an item move mode changed
*/
export type DashboardItemMoveModeChangedEvent<TItem extends DashboardItem> = CustomEvent<{
item: TItem;
item: TItem | DashboardSectionItem<TItem>;
value: boolean;
}>;

Expand Down
12 changes: 8 additions & 4 deletions packages/dashboard/test/typings/dashboard.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ assertType<Array<TestDashboardItem | DashboardSectionItem<TestDashboardItem>>>(s

narrowedDashboard.addEventListener('dashboard-item-moved', (event) => {
assertType<DashboardItemMovedEvent<TestDashboardItem>>(event);
assertType<TestDashboardItem>(event.detail.item);
assertType<TestDashboardItem>(event.detail.item as TestDashboardItem);
assertType<DashboardSectionItem<TestDashboardItem>>(event.detail.item as DashboardSectionItem<TestDashboardItem>);
assertType<Array<TestDashboardItem | DashboardSectionItem<TestDashboardItem>>>(event.detail.items);
assertType<DashboardSectionItem<TestDashboardItem> | undefined>(event.detail.section);
});
Expand All @@ -88,19 +89,22 @@ narrowedDashboard.addEventListener('dashboard-item-resized', (event) => {

narrowedDashboard.addEventListener('dashboard-item-removed', (event) => {
assertType<DashboardItemRemovedEvent<TestDashboardItem>>(event);
assertType<TestDashboardItem | DashboardSectionItem<TestDashboardItem>>(event.detail.item);
assertType<TestDashboardItem>(event.detail.item as TestDashboardItem);
assertType<DashboardSectionItem<TestDashboardItem>>(event.detail.item as DashboardSectionItem<TestDashboardItem>);
assertType<Array<TestDashboardItem | DashboardSectionItem<TestDashboardItem>>>(event.detail.items);
});

narrowedDashboard.addEventListener('dashboard-item-selected-changed', (event) => {
assertType<DashboardItemSelectedChangedEvent<TestDashboardItem>>(event);
assertType<TestDashboardItem>(event.detail.item);
assertType<TestDashboardItem>(event.detail.item as TestDashboardItem);
assertType<DashboardSectionItem<TestDashboardItem>>(event.detail.item as DashboardSectionItem<TestDashboardItem>);
assertType<boolean>(event.detail.value);
});

narrowedDashboard.addEventListener('dashboard-item-move-mode-changed', (event) => {
assertType<DashboardItemMoveModeChangedEvent<TestDashboardItem>>(event);
assertType<TestDashboardItem>(event.detail.item);
assertType<TestDashboardItem>(event.detail.item as TestDashboardItem);
assertType<DashboardSectionItem<TestDashboardItem>>(event.detail.item as DashboardSectionItem<TestDashboardItem>);
assertType<boolean>(event.detail.value);
});

Expand Down

0 comments on commit 0bf0d91

Please sign in to comment.