Skip to content

Commit

Permalink
Fix(web, web-twig): FileUploader changed selectors in JS plugin
Browse files Browse the repository at this point in the history
- Changed class selectors for data selectors in JS plugin
  • Loading branch information
pavelklibani committed Nov 7, 2023
1 parent a7175d8 commit cdc8e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/web/src/js/FileUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class FileUploader extends BaseComponent {
const itemButton = snippet.querySelector(`[${TEMPLATE_ELEMENT_SLOT_NAME}="button"]`);
const hasImagePreview = Boolean((item as HTMLElement)?.dataset?.spiritImagepreview);
const AttachmentSvgIcon = item?.querySelector('svg');
const AttachmentPreviewImage = snippet.querySelector('.FileUploaderAttachment__image');
const AttachmentPreviewImage = item?.querySelector('[data-spirit-element="attachment-image"]');
const isFileImg = file.type.includes('image');

if (hasImagePreview && isFileImg) {
Expand Down Expand Up @@ -379,7 +379,9 @@ class FileUploader extends BaseComponent {

this.fileQueue.set(name, newValue);

const itemImgElement = SelectorEngine.findOne(`#${name} .FileUploaderAttachment__image img`) as HTMLImageElement;
const itemImgElement = SelectorEngine.findOne(
`#${name} [data-spirit-element="attachment-image"] img`,
) as HTMLImageElement;

if (meta && itemImgElement && FileUploader.isCoordsInMeta(meta)) {
const previewHeight = IMAGE_PREVIEW_HEIGHT;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/scss/components/FileUploader/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ <h2 class="docs-Heading">FileUploader with Meta Data</h2>
<!-- FileUploaderAttachment template: start -->
<template data-spirit-snippet="item">
<li class="FileUploaderAttachment" data-spirit-populate-field="item" data-spirit-imagePreview="true">
<span class="FileUploaderAttachment__image">
<span class="FileUploaderAttachment__image" data-spirit-element="attachment-image">
<img src="" width="54" height="54" alt="" />
</span>
<svg width="24" height="24" aria-hidden="true">
Expand Down

0 comments on commit cdc8e7c

Please sign in to comment.