Skip to content

Commit

Permalink
fix: excess render calls for the FileItem on "Add more"
Browse files Browse the repository at this point in the history
  • Loading branch information
foxeyes committed Apr 12, 2022
1 parent 6a78077 commit 655747a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion blocks/FileItem/FileItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ export class FileItem extends Block {
}

initCallback() {
super.initCallback();
this.bindCssData('--cfg-thumb-size');
this.defineAccessor('entry-id', (id) => {
if (!id) {
if (!id || id === this.uid) {
return;
}
/** @type {String} */
Expand Down
8 changes: 6 additions & 2 deletions blocks/UploadList/UploadList.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ export class UploadList extends Block {
let fr = document.createDocumentFragment();
Object.values(this._renderMap).forEach((el) => fr.appendChild(el));
this.ref.files.replaceChildren(fr);
Object.entries(this._renderMap).forEach(([id, el]) => {
Object.keys(this._renderMap).forEach((id) => {
/** @type {Block} */
let el = this._renderMap[id];
// rendering components async improves initial list render time a bit
setTimeout(() => {
el['entry-id'] = id;
el.render();
if (!el.innerHTML) {
el.render();
}
});
});
});
Expand Down

0 comments on commit 655747a

Please sign in to comment.