From 54e9b7a8813cb6e8fe17457a6d2d80c1f35c26c0 Mon Sep 17 00:00:00 2001 From: vsandvold <6734787+vsandvold@users.noreply.github.com> Date: Thu, 6 Jan 2022 16:14:14 +0100 Subject: [PATCH 1/2] fix: add button type attribute to affix buttons --- packages/_helpers/affix.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/_helpers/affix.tsx b/packages/_helpers/affix.tsx index 797fad1b..67b2a801 100644 --- a/packages/_helpers/affix.tsx +++ b/packages/_helpers/affix.tsx @@ -28,10 +28,19 @@ interface AffixProps { export function Affix(props: AffixProps) { const classBase = props.prefix ? prefix : suffix; + let buttonType; + if (props.search) { + buttonType = 'submit'; + } + if (props.clear) { + buttonType = 'reset'; + } + return React.createElement( props.label ? 'div' : 'button', { 'aria-label': !props.label ? props['aria-label'] : undefined, + type: buttonType, onClick: props.onClick, className: classNames({ [classBase.wrapper]: true, From 4423af7cce649c8b0173dd46420044fe2965ffeb Mon Sep 17 00:00:00 2001 From: Benjamin Akar Date: Mon, 17 Jan 2022 11:30:50 +0100 Subject: [PATCH 2/2] refactor to use ternary, nitpick --- packages/_helpers/affix.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/_helpers/affix.tsx b/packages/_helpers/affix.tsx index 67b2a801..f44bc1e4 100644 --- a/packages/_helpers/affix.tsx +++ b/packages/_helpers/affix.tsx @@ -28,19 +28,11 @@ interface AffixProps { export function Affix(props: AffixProps) { const classBase = props.prefix ? prefix : suffix; - let buttonType; - if (props.search) { - buttonType = 'submit'; - } - if (props.clear) { - buttonType = 'reset'; - } - return React.createElement( props.label ? 'div' : 'button', { 'aria-label': !props.label ? props['aria-label'] : undefined, - type: buttonType, + type: props.search ? 'submit' : props.clear ? 'reset' : undefined, onClick: props.onClick, className: classNames({ [classBase.wrapper]: true,