Working type submit for forms - Button Component

This commit is contained in:
Belen Curcio
2018-08-16 12:41:21 -03:00
parent a48bcc3076
commit ecb82cf9a9
3 changed files with 22 additions and 4 deletions
@@ -32,6 +32,8 @@ interface InnerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/** Internal: Forwarded Ref */
forwardRef?: Ref<HTMLButtonElement>;
type?: "submit" | "reset" | "button";
}
/**
@@ -45,15 +47,17 @@ const BaseButton: StatelessComponent<InnerProps> = ({
keyboardFocus,
mouseHover,
forwardRef,
type: typeProp,
type,
...rest
}) => {
console.log("type", type, "Basebutton");
let Element = "button";
if (anchor) {
Element = "a";
}
let type = typeProp;
if (anchor && type) {
// tslint:disable:next-line: no-console
console.warn(
@@ -69,7 +73,9 @@ const BaseButton: StatelessComponent<InnerProps> = ({
[classes.mouseHover]: mouseHover,
});
return <Element {...rest} className={rootClassName} ref={forwardRef} />;
return (
<Element {...rest} className={rootClassName} ref={forwardRef} type={type} />
);
};
const enhanced = withForwardRef(