From ed28591b62cd2dc0b6eac94d06d7c7cd776a48b9 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 15 Sep 2020 13:03:05 -0500 Subject: [PATCH] fix link regression (#9408) Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com> --- .../components/ui/button/button.component.js | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/ui/app/components/ui/button/button.component.js b/ui/app/components/ui/button/button.component.js index d0405aa3d..c82e52c2a 100644 --- a/ui/app/components/ui/button/button.component.js +++ b/ui/app/components/ui/button/button.component.js @@ -25,22 +25,33 @@ const typeHash = { 'first-time': CLASSNAME_FIRST_TIME, } -const Button = ({ type, submit, large, children, icon, rounded, className, ...buttonProps }) => ( - -) +const Button = ({ type, submit, large, children, icon, rounded, className, ...buttonProps }) => { + // To support using the Button component to render styled links that are semantic html + // we swap the html tag we use to render this component and delete any buttonProps that + // we know to be erroneous attributes for a link. We will likely want to extract Link + // to its own component in the future. + let Tag = 'button' + if (type === 'link') { + Tag = 'a' + } else if (submit) { + buttonProps.type = 'submit' + } + return ( + + {icon && {icon}} + { children } + + ) +} Button.propTypes = { type: PropTypes.string,