react-awesome-button icon indicating copy to clipboard operation
react-awesome-button copied to clipboard

Using the button as a Submit button

Open avi747av opened this issue 5 years ago • 6 comments

Hi I'm trying to use this really Awesome button to submit a form (I'm using Formik) but I get a warning in the console that it's better to add type = submit but I can't because here the type means something else - the color of the button.

this is the warning:

Warning: You submitted a Formik form using a button with an unspecified type attribute. Most browsers default button elements to type="submit". If this is not a submit button, please add type="button".

Best regards Avi

avi747av avatar Jan 29 '20 14:01 avi747av

A related note: I'd like to use an AwesomeButton not as submit, but can't since there's no way to override the default <button> type.
In other words, if an AwesomeButton appears on a page with a <form>, the button will always submit the form.

ugumba avatar Mar 08 '21 11:03 ugumba

this works:

<AwesomeButtonProgress
      element={({children, style, className}) =>
          <button style={style} className={className}
              type={'submit'}>{children}</button>}>
hello
</AwesomeButtonProgress>

jodinathan avatar Apr 07 '21 15:04 jodinathan

@jodinathan it breaks my hover and press events. I did it like this:

class MyAwesomeButton extends AwesomeButton {
	constructor(props) {
		super(props);
		this.extraProps = {
			type: props.buttonType,
		};
	}
}

<MyAwesomeButton buttonType="submit|button" />

meliborn avatar Apr 16 '21 11:04 meliborn

Awesomebuttonprogress , Is it html tag or an imported component?

Princejain21 avatar Apr 10 '22 07:04 Princejain21

This is an absolute killer of an issue. I really want to use this library, but i am not maintaining button hacks site wide. This should be addressed as this library is awesome, but this problem is a deal breaker. :(

The typescript version is even worse! And it loses the animation effect. :(

    <AwesomeButton
      type={type}
      size="large"
      before={props.startIcon}
      disabled={props.disabled}
      element={
        childElement as React.ForwardRefExoticComponent<
          React.RefAttributes<
            HTMLAnchorElement | HTMLDivElement | HTMLButtonElement
          >
        >
      }
    >
      {props.children}
    </AwesomeButton>

This does indeed work, but i lose the animated button wobble. Everything else looks good, i think.

Neuroforge avatar Aug 16 '23 09:08 Neuroforge

Ok.

This works as the element and maintains the animation.,

const NestedButton = forwardRef<HTMLButtonElement>((props, ref) => (
  <button ref={ref} {...props} />
));

Neuroforge avatar Aug 17 '23 12:08 Neuroforge