🎉 Set default button behaviour as type button instead of submit (#7741)

This commit is contained in:
Xaviju 2025-11-14 10:25:38 +01:00 committed by GitHub
parent 839bb470df
commit 2233f34a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,7 @@
(def ^:private schema:button
[:map
[:class {:optional true} :string]
[:type {:optional true} [:maybe [:enum "button" "submit" "reset"]]]
[:icon {:optional true}
[:and :string [:fn #(contains? icon-list %)]]]
[:on-ref {:optional true} fn?]
@ -24,7 +25,7 @@
(mf/defc button*
{::mf/schema schema:button}
[{:keys [variant icon children class on-ref to] :rest props}]
[{:keys [variant icon children class on-ref to type] :rest props}]
(let [variant (d/nilv variant "primary")
element (if to "a" "button")
internal-class (stl/css-case :button true
@ -35,6 +36,7 @@
:button-destructive (= variant "destructive"))
props (mf/spread-props props {:class [class internal-class]
:href to
:type (d/nilv type "button")
:ref (fn [node]
(when on-ref
(on-ref node)))})]

View File

@ -28,6 +28,7 @@ export default {
children: "Lorem ipsum",
disabled: false,
variant: undefined,
type: "button",
},
parameters: {
controls: { exclude: ["children"] },

View File

@ -48,10 +48,12 @@
(when cancel-label
[:> button* {:variant "secondary"
:type "button"
:on-click on-cancel}
cancel-label])
(when accept-label
[:> button* {:variant (if (= variant "default") "primary" "destructive")
:type "button"
:on-click on-accept}
accept-label])]))

View File

@ -70,6 +70,7 @@
[:img {:class (stl/css :resolved-image) :src (cf/resolve-file-media image)}]]
[:> button* {:class (stl/css :download-button)
:type "button"
:variant "secondary"
:target "_blank"
:download name

View File

@ -120,6 +120,7 @@
:alt (tr "inspect.attributes.image.preview")}]]
[:> button* {:variant "secondary"
:to color-image-url
:type "button"
:target "_blank"
:download color-image-name}
(tr "inspect.attributes.image.download")]])]))

View File

@ -79,6 +79,7 @@
[:> button* {:class (stl/css :open-button)
:variant "secondary"
:type "button"
:on-click handle-open-click
:title (when-not can-open? (tr "workspace.plugins.error.need-editor"))
:disabled (not can-open?)} (tr "workspace.plugins.button-open")]

View File

@ -1089,6 +1089,7 @@
(when (and multi all-main? (not any-variant?))
[:> button* {:variant "secondary"
:type "button"
:class (stl/css :component-combine)
:on-click on-combine-as-variants}
(tr "workspace.shape.menu.combine-as-variants")])

View File

@ -96,6 +96,7 @@
[:div {:class (stl/css :button-row)}
[:> button* {:variant "primary"
:type "button"
:class (stl/css :modal-accept-btn)
:on-click on-close}
(tr "ds.confirm-ok")]]]]))

View File

@ -100,9 +100,11 @@
[:div {:class (stl/css :settings-modal-actions)}
[:> button* {:on-click modal/hide!
:type "button"
:variant "secondary"}
(tr "labels.cancel")]
[:> button* {:on-click on-set-font
:type "button"
:disabled (not is-valid)
:variant "primary"}
(tr "labels.save")]]]]]]))

View File

@ -116,6 +116,7 @@
[:div {:class (stl/css :import-export-button-wrapper)}
[:> button* {:on-click open-menu
:type "button"
:icon i/import-export
:variant "secondary"}
(tr "workspace.tokens.tools")]

View File

@ -46,6 +46,7 @@
[:div {:class (stl/css :theme-selector-wrapper)}
[:& theme-selector]
[:> button* {:variant "secondary"
:type "button"
:class (stl/css :edit-theme-button)
:on-click open-modal}
(tr "labels.edit")]]