diff --git a/packages/material-ui/src/IconButton/IconButton.d.ts b/packages/material-ui/src/IconButton/IconButton.d.ts index 9ccb256618e16c..7f07f8b83c6221 100644 --- a/packages/material-ui/src/IconButton/IconButton.d.ts +++ b/packages/material-ui/src/IconButton/IconButton.d.ts @@ -4,8 +4,9 @@ import { SimplifiedPropsOf } from '../OverridableComponent'; declare const IconButton: ExtendButtonBase<{ props: { - edge?: 'start' | 'end' | false; color?: PropTypes.Color; + disableFocusRipple?: boolean; + edge?: 'start' | 'end' | false; size?: 'small' | 'medium'; }; defaultComponent: 'button'; diff --git a/packages/material-ui/src/IconButton/IconButton.js b/packages/material-ui/src/IconButton/IconButton.js index 879c02a073e942..a45e9098691a09 100644 --- a/packages/material-ui/src/IconButton/IconButton.js +++ b/packages/material-ui/src/IconButton/IconButton.js @@ -100,6 +100,7 @@ const IconButton = React.forwardRef(function IconButton(props, ref) { className, color = 'default', disabled = false, + disableFocusRipple = false, size = 'medium', ...other } = props; @@ -118,7 +119,7 @@ const IconButton = React.forwardRef(function IconButton(props, ref) { className, )} centerRipple - focusRipple + focusRipple={!disableFocusRipple} disabled={disabled} ref={ref} {...other} @@ -168,6 +169,15 @@ IconButton.propTypes = { * If `true`, the button will be disabled. */ disabled: PropTypes.bool, + /** + * If `true`, the keyboard focus ripple will be disabled. + * `disableRipple` must also be true. + */ + disableFocusRipple: PropTypes.bool, + /** + * If `true`, the ripple effect will be disabled. + */ + disableRipple: PropTypes.bool, /** * If given, uses a negative margin to counteract the padding on one * side (this is often helpful for aligning the left or right diff --git a/packages/material-ui/src/IconButton/IconButton.test.js b/packages/material-ui/src/IconButton/IconButton.test.js index 12e8d0ff79ff99..a8a7ad71cd2bd5 100644 --- a/packages/material-ui/src/IconButton/IconButton.test.js +++ b/packages/material-ui/src/IconButton/IconButton.test.js @@ -77,6 +77,16 @@ describe('', () => { assert.strictEqual(wrapper.props().centerRipple, true); }); + it('should have a focusRipple by default', () => { + const wrapper = shallow(book); + assert.strictEqual(wrapper.props().focusRipple, true); + }); + + it('should pass disableFocusRipple to ButtonBase', () => { + const wrapper = shallow(book); + assert.strictEqual(wrapper.props().focusRipple, false); + }); + describe('prop: size', () => { it('should render the right class', () => { let wrapper; diff --git a/packages/material-ui/src/Tab/Tab.d.ts b/packages/material-ui/src/Tab/Tab.d.ts index 912defd92b6175..9ee126e78ed265 100644 --- a/packages/material-ui/src/Tab/Tab.d.ts +++ b/packages/material-ui/src/Tab/Tab.d.ts @@ -4,15 +4,16 @@ import { SimplifiedPropsOf } from '../OverridableComponent'; declare const Tab: ExtendButtonBase<{ props: { + disableFocusRipple?: boolean; fullWidth?: boolean; icon?: string | React.ReactElement; - value?: any; label?: React.ReactNode; onChange?: (event: React.ChangeEvent<{ checked: boolean }>, value: any) => void; onClick?: React.EventHandler; selected?: boolean; style?: React.CSSProperties; textColor?: string | 'secondary' | 'primary' | 'inherit'; + value?: any; wrapped?: boolean; }; defaultComponent: 'div'; diff --git a/packages/material-ui/src/Tab/Tab.js b/packages/material-ui/src/Tab/Tab.js index af9ab96becdafd..b2c83b442b55f8 100644 --- a/packages/material-ui/src/Tab/Tab.js +++ b/packages/material-ui/src/Tab/Tab.js @@ -98,6 +98,7 @@ const Tab = React.forwardRef(function Tab(props, ref) { classes, className, disabled = false, + disableFocusRipple = false, fullWidth, icon, indicator, @@ -123,7 +124,7 @@ const Tab = React.forwardRef(function Tab(props, ref) { return ( ', () => { skip: ['componentProp'], })); + it('should have a ripple by default', () => { + const wrapper = shallow(); + assert.strictEqual(wrapper.props().disableRipple, undefined); + }); + + it('should pass disableRipple to ButtonBase', () => { + const wrapper = shallow(); + assert.strictEqual(wrapper.props().disableRipple, true); + }); + + it('should have a focusRipple by default', () => { + const wrapper = shallow(); + assert.strictEqual(wrapper.props().focusRipple, true); + }); + + it('should pass disableFocusRipple to ButtonBase', () => { + const wrapper = shallow(); + assert.strictEqual(wrapper.props().focusRipple, false); + }); + describe('prop: selected', () => { it('should render with the selected and root classes', () => { const wrapper = mount(); diff --git a/pages/api/icon-button.md b/pages/api/icon-button.md index 3736835608a377..923e5794443d57 100644 --- a/pages/api/icon-button.md +++ b/pages/api/icon-button.md @@ -23,6 +23,8 @@ regarding the available icon options. | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | color | enum: 'default' |
 'inherit' |
 'primary' |
 'secondary'
| 'default' | The color of the component. It supports those theme colors that make sense for this component. | | disabled | bool | false | If `true`, the button will be disabled. | +| disableFocusRipple | bool | false | If `true`, the keyboard focus ripple will be disabled. `disableRipple` must also be true. | +| disableRipple | bool | | If `true`, the ripple effect will be disabled. | | edge | enum: 'start' |
 'end' |
 false
| false | If given, uses a negative margin to counteract the padding on one side (this is often helpful for aligning the left or right side of the icon with content above or below, without ruining the border size and shape). | | size | enum: 'small' |
 'medium'
| 'medium' | The size of the button. `small` is equivalent to the dense button styling. | diff --git a/pages/api/tab.md b/pages/api/tab.md index e67eab0c78f61f..67257f1a2a4b95 100644 --- a/pages/api/tab.md +++ b/pages/api/tab.md @@ -21,6 +21,8 @@ import Tab from '@material-ui/core/Tab'; | children | unsupportedProp | | This property isn't supported. Use the `component` property if you need to change the children structure. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | disabled | bool | false | If `true`, the tab will be disabled. | +| disableFocusRipple | bool | false | If `true`, the keyboard focus ripple will be disabled. `disableRipple` must also be true. | +| disableRipple | bool | | If `true`, the ripple effect will be disabled. | | icon | node | | The icon element. | | label | node | | The label element. | | value | any | | You can provide your own value. Otherwise, we fallback to the child position index. |