{
describe('customized icon', () => {
it('renders', () => {
- const rootWrapper = shallow(
+ const rootWrapper = mount(
Other
}>
@@ -204,7 +204,12 @@ describe('OverflowMenu', () => {
);
- expect(rootWrapper.find('.bx--overflow-menu__icon')).toHaveLength(0);
+ // renderIcon should be the only component where `bx--overflow-menu__icon` class is applied,
+ // meaning no actual DOM node should have that class
+ const nodesWithIconClasses = rootWrapper.find('.bx--overflow-menu__icon');
+ expect(nodesWithIconClasses.length).toBe(
+ nodesWithIconClasses.filter('renderIcon').length
+ );
expect(rootWrapper.find('.other')).toHaveLength(1);
});
});
diff --git a/src/components/OverflowMenu/OverflowMenu.js b/src/components/OverflowMenu/OverflowMenu.js
index d31b3fa168..305eaf4fa6 100644
--- a/src/components/OverflowMenu/OverflowMenu.js
+++ b/src/components/OverflowMenu/OverflowMenu.js
@@ -20,11 +20,13 @@ import FloatingMenu, {
import OptimizedResize from '../../internal/OptimizedResize';
import Icon from '../Icon';
import OverflowMenuVertical16 from '@carbon/icons-react/lib/overflow-menu--vertical/16';
-import { componentsX } from '../../internal/FeatureFlags';
+import { breakingChangesX, componentsX } from '../../internal/FeatureFlags';
import { keys, matches as keyCodeMatches } from '../../tools/key';
const { prefix } = settings;
+let didWarnAboutDeprecation = false;
+
const matchesFuncName =
typeof Element !== 'undefined' &&
['matches', 'webkitMatchesSelector', 'msMatchesSelector'].filter(
@@ -275,7 +277,7 @@ export default class OverflowMenu extends Component {
/**
* Function called to override icon rendering.
*/
- renderIcon: PropTypes.func,
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
/**
* Function called when menu is closed
@@ -295,6 +297,7 @@ export default class OverflowMenu extends Component {
direction: DIRECTION_BOTTOM,
flipped: false,
floatingMenu: false,
+ renderIcon: !componentsX ? undefined : OverflowMenuVertical16,
onClick: () => {},
onKeyDown: () => {},
onClose: () => {},
@@ -557,7 +560,7 @@ export default class OverflowMenu extends Component {
iconClass,
onClick, // eslint-disable-line
onOpen, // eslint-disable-line
- renderIcon,
+ renderIcon: IconElement,
...other
} = this.props;
@@ -569,6 +572,15 @@ export default class OverflowMenu extends Component {
);
}
+ if (__DEV__ && breakingChangesX && (icon || iconName)) {
+ warning(
+ didWarnAboutDeprecation,
+ 'The `icon`/`iconName` properties in the `OverflowMenu` component is being removed in the next release of ' +
+ '`carbon-components-react`. Please use `renderIcon` instead.'
+ );
+ didWarnAboutDeprecation = true;
+ }
+
const { open } = this.state;
const overflowMenuClasses = classNames(
@@ -644,19 +656,15 @@ export default class OverflowMenu extends Component {
};
const overflowMenuIcon = (() => {
- if (renderIcon) {
- return renderIcon(iconProps);
- }
- if (!componentsX) {
- return (
-
- );
- }
- return ;
+ return IconElement ? (
+
+ ) : (
+
+ );
})();
return (
diff --git a/src/components/Tooltip/Tooltip.js b/src/components/Tooltip/Tooltip.js
index d5694e7087..14bb197105 100644
--- a/src/components/Tooltip/Tooltip.js
+++ b/src/components/Tooltip/Tooltip.js
@@ -109,7 +109,8 @@ const getMenuOffset = (menuBody, menuDirection) => {
}
};
-let didWarnAboutDeprecation = false;
+let didWarnAboutDeprecationClickToOpen = false;
+let didWarnAboutDeprecationIcon = false;
export default class Tooltip extends Component {
state = {};
@@ -225,6 +226,7 @@ export default class Tooltip extends Component {
static defaultProps = {
open: false,
direction: DIRECTION_BOTTOM,
+ renderIcon: !componentsX ? undefined : Information,
showIcon: true,
iconDescription: 'tooltip',
iconTitle: '',
@@ -390,7 +392,7 @@ export default class Tooltip extends Component {
iconName,
iconTitle,
iconDescription,
- renderIcon,
+ renderIcon: IconCustomElement,
menuOffset,
// Exclude `clickToOpen` from `other` to avoid passing it along to ``
clickToOpen,
@@ -400,11 +402,20 @@ export default class Tooltip extends Component {
if (!clickToOpen && __DEV__) {
warning(
- didWarnAboutDeprecation,
+ didWarnAboutDeprecationClickToOpen,
'The `clickToOpen=false` option in `Tooltip` component is being updated in the next release of ' +
'`carbon-components-react`. Please use `TooltipIcon` or `TooltipDefinition` instead.'
);
- didWarnAboutDeprecation = true;
+ didWarnAboutDeprecationClickToOpen = true;
+ }
+
+ if (__DEV__ && breakingChangesX && (icon || iconName)) {
+ warning(
+ didWarnAboutDeprecationIcon,
+ 'The `icon`/`iconName` properties in the `Tooltip` component is being removed in the next release of ' +
+ '`carbon-components-react`. Please use `renderIcon` instead.'
+ );
+ didWarnAboutDeprecationIcon = true;
}
const { open } = this.state;
@@ -426,8 +437,6 @@ export default class Tooltip extends Component {
'aria-owns': tooltipId,
};
- const IconCustomElement = renderIcon || (componentsX && Information);
-
const finalIcon = IconCustomElement ? (