Skip to content

Commit ac80d4e

Browse files
committed
fix
1 parent 546f133 commit ac80d4e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

templates/shared/avatar_upload_crop.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- /* we do not need to set for/id here, global aria init code will add them automatically */ -}}
22
<label>{{.LabelText}}</label>
33
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
4-
{{- /* the cropper-panel must be next sibling of the input "js-avatar-with-cropper" */ -}}
4+
{{- /* the cropper-panel must be next sibling of the input "avatar" */ -}}
55
<div class="cropper-panel tw-hidden">
66
<div>{{ctx.Locale.Tr "settings.cropper_prompt"}}</div>
77
<div class="cropper-wrapper"><img class="cropper-source" src alt></div>

web_src/js/features/comp/Cropper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ async function initCompCropper({container, fileInput, imageSource}: CropperOpts)
4141

4242
export async function initAvatarUploaderWithCropper(fileInput?: HTMLInputElement) {
4343
if (!fileInput) return;
44-
const panel = queryElemSiblings(fileInput, '.cropper-panel')[0] as HTMLElement;
45-
if (!panel) return;
44+
const panel = fileInput.nextElementSibling as HTMLElement;
45+
if (!panel?.matches('.cropper-panel')) throw new Error('Missing cropper panel for avatar uploader');
4646
const imageSource = panel.querySelector<HTMLImageElement>('.cropper-source');
4747
await initCompCropper({container: panel, fileInput, imageSource});
4848
}

0 commit comments

Comments
 (0)