Add 'type' of "button" to default toggle button props?
-
downshiftversion: 6.1.7 -
nodeversion: 14.17.4 -
npm(oryarn) version: yarn 1.22.11
Relevant code or config
const {
getToggleButtonProps,
...rest
} = useSelect(...);
const toggleButtonProps = getToggleButtonProps();
expect(toggleButtonProps.type).toEqual('button');
Problem description:
When using one of the Downshift hooks (select or combobox), the props that come back from getToggleButtonProps do not contain a default type attribute. If a type attribute is not given, the button will have a default of type="submit".
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type
I see a similar issue (#1274) stating that "useSelect doesn't work inside forms".
Suggested solution:
Does anyone think it would be worthwhile to add type: 'button' to the default set of attributes returned from getToggleButtonProps? It wouldn't technically be a valid attribute if passed to a non-<button> element, but I don't think it causes any negative effects.
Or is this best left in user-land, with the consumer applying type="button" to their toggle button in addition to spreading getToggleButtonProps?
Thanks!