From 5a543f8abd97634f7791e37f18e1eca4e9a98418 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 16 Oct 2019 10:05:46 +0200 Subject: [PATCH] FIX: prevents trash button to get focus when submiting input on profile (#8198) This is a default behavior for browsers to submit using first button which doesn't have `type="button"` in a form when pressing enter inside an input. --- .../templates/components/image-uploader.hbs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/templates/components/image-uploader.hbs b/app/assets/javascripts/discourse/templates/components/image-uploader.hbs index 24f33864fec..e0d4ffe77a5 100644 --- a/app/assets/javascripts/discourse/templates/components/image-uploader.hbs +++ b/app/assets/javascripts/discourse/templates/components/image-uploader.hbs @@ -9,15 +9,21 @@ {{#if imageUrl}} - - {{/if}} + {{d-button + action=(action "trash") + class="btn-danger pad-left no-text" + icon="far-trash-alt" + type="button" + }} - {{#if imageUrl}} - {{d-button icon="discourse-expand" - title='expand' - class="btn image-uploader-lightbox-btn no-text" - action=(action "toggleLightbox") - disabled=loadingLightbox}} + {{d-button + icon="discourse-expand" + title="expand" + type="button" + class="image-uploader-lightbox-btn no-text" + action=(action "toggleLightbox") + disabled=loadingLightbox + }} {{/if}} {{i18n 'upload_selector.uploading'}} {{uploadProgress}}%