fix: only calculate a new preview element when the 'value' changes
This commit is contained in:
@@ -74,6 +74,14 @@ export class UmbInputUploadFieldElement extends UmbLitElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
override updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>) {
|
||||
super.updated(changedProperties);
|
||||
if (changedProperties.has('value')) {
|
||||
this.#setPreviewAlias();
|
||||
}
|
||||
}
|
||||
|
||||
async #getManifests() {
|
||||
await new UmbExtensionsManifestInitializer(this, umbExtensionsRegistry, 'fileUploadPreview', null, (exts) => {
|
||||
@@ -92,6 +100,10 @@ export class UmbInputUploadFieldElement extends UmbLitElement {
|
||||
this._extensions = extensions?.map((extension) => `.${extension}`);
|
||||
}
|
||||
|
||||
async #setPreviewAlias(): Promise<void> {
|
||||
this._previewAlias = await this.#getPreviewElementAlias();
|
||||
}
|
||||
|
||||
async #getPreviewElementAlias() {
|
||||
if (!this.value.src) return;
|
||||
const manifests = await this.#getManifests();
|
||||
|
||||
Reference in New Issue
Block a user