Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/pages/material-ui/api/button-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"name": "union",
"description": "func<br>&#124;&nbsp;{ current?: { pulsate: func, start: func, stop: func } }"
}
}
},
"type": { "type": { "name": "string" }, "default": "'button'" }
},
"name": "ButtonBase",
"imports": [
Expand Down
3 changes: 3 additions & 0 deletions docs/translations/api-docs/button-base/button-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"TouchRippleProps": { "description": "Props applied to the <code>TouchRipple</code> element." },
"touchRippleRef": {
"description": "A ref that points to the <code>TouchRipple</code> element."
},
"type": {
"description": "The HTML <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type\"><code>type</code></a> attribute."
}
},
"classDescriptions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ Button.propTypes /* remove-proptypes */ = {
/**
* @ignore
*/
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this considered a breaking change? probably not since we are expanding the allowed values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah widening the type is ok ~

type: PropTypes.string,
/**
* The variant to use.
* @default 'text'
Expand Down
7 changes: 7 additions & 0 deletions packages/mui-material/src/ButtonBase/ButtonBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ export interface ButtonBaseOwnProps {
* A ref that points to the `TouchRipple` element.
*/
touchRippleRef?: React.Ref<TouchRippleActions> | undefined;
/**
* The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type)
* attribute applied to `button` and `a` elements.
* Ignored when rendering non-native buttons.
* @default 'button'
*/
type?: string | undefined;
}

export interface ButtonBaseTypeMap<
Expand Down
5 changes: 3 additions & 2 deletions packages/mui-material/src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,10 @@ ButtonBase.propTypes /* remove-proptypes */ = {
}),
]),
/**
* @ignore
* The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type) attribute.
* @default 'button'
*/
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
type: PropTypes.string,
};

export default ButtonBase;
1 change: 0 additions & 1 deletion packages/mui-material/src/ButtonBase/ButtonBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,6 @@ describe('<ButtonBase />', () => {
});

it('allows non-standard values', () => {
// @ts-expect-error `@types/react` only lists standard values
render(<ButtonBase type="fictional-type" />);

expect(screen.getByRole('button')).to.have.attribute('type', 'fictional-type');
Expand Down
Loading