Skip to content

Commit

Permalink
fix: removed composed: true and bubbles: true and set eventlistener d…
Browse files Browse the repository at this point in the history
…irectly on lion-selected-file-list
  • Loading branch information
DannyMoerkerke committed Jun 20, 2023
1 parent 24913a5 commit 19e603a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .changeset/popular-plants-sparkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@lion/ui': patch
---

lion-selected-filelist: restored composed: true and bubbles: true for 'file-remove-requested' event, otherwise removing files for subclassers won't work
lion-selected-filelist: removed composed: true and bubbles: true and set eventlistener directly on lion-selected-file-list inside lion-input-file
16 changes: 12 additions & 4 deletions packages/ui/components/input-file/src/LionInputFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,17 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
this.__duplicateFileNamesValidator = new DuplicateFileNames({ show: false });
}

get _fileListNode() {
return Array.from(this.children).find(child => child.slot === 'selected-file-list')
?.children[0];
}

connectedCallback() {
super.connectedCallback();
this.__initialUploadResponse = this.uploadResponse;

this._inputNode.addEventListener('change', this._onChange);
this._inputNode.addEventListener('click', this._onClick);
this.addEventListener(
'file-remove-requested',
/** @type {EventListener} */ (this._onRemoveFile),
);
}

disconnectedCallback() {
Expand Down Expand Up @@ -347,6 +348,13 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
this.__setupDragDropEventListeners();
this.setAttribute('drop-zone', '');
}

console.log(this._fileListNode);

/** @type {LionSelectedFileList} */ (this._fileListNode).addEventListener(
'file-remove-requested',
/** @type {EventListener} */ (this._onRemoveFile),
);
}

/**
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/components/input-file/src/LionSelectedFileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export class LionSelectedFileList extends LocalizeMixin(ScopedElementsMixin(LitE
_removeFile(removedFile) {
this.dispatchEvent(
new CustomEvent('file-remove-requested', {
composed: true,
bubbles: true,
detail: {
removedFile,
status: removedFile.status,
Expand Down

0 comments on commit 19e603a

Please sign in to comment.