Skip to content

Commit

Permalink
allow closing the dialog with the top right x icon, and fix an issue …
Browse files Browse the repository at this point in the history
…with initial states
  • Loading branch information
emma-sg committed Jan 30, 2025
1 parent 8eb179d commit 77a47ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions frontend/src/features/collections/collection-edit-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export class CollectionEdit extends BtrixElement {
| undefined) || null;

@state()
selectedSnapshot: CollectionThumbnailSource | null = null;
selectedSnapshot: CollectionThumbnailSource | null =
this.collection?.thumbnailSource ?? null;

@state()
blobIsLoaded = false;
Expand Down Expand Up @@ -170,8 +171,12 @@ export class CollectionEdit extends BtrixElement {
this.dirty = false;
this.errorTab = null;
this.blobIsLoaded = false;
this.selectedSnapshot = null;
this.defaultThumbnailName = null;
this.selectedSnapshot = this.collection?.thumbnailSource ?? null;
this.defaultThumbnailName =
(this.collection?.defaultThumbnailName as
| `${Thumbnail}`
| null
| undefined) || null;
}

protected firstUpdated(): void {
Expand All @@ -193,6 +198,10 @@ export class CollectionEdit extends BtrixElement {
this.tab = "general";
}}
@sl-request-close=${(e: SlRequestCloseEvent) => {
if (e.detail.source === "close-button") {
this.onReset();
return;
}
// Prevent accidental closes unless data has been saved
// Closing via the close buttons is fine though, cause it resets the form first.
if (this.dirty) e.preventDefault();
Expand Down

0 comments on commit 77a47ec

Please sign in to comment.