From 09b01ba2225b2b52ef71aebd559e62292c1fa6c4 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Thu, 20 Oct 2016 21:24:56 +0200 Subject: [PATCH] [Popover] Fix support for invalid anchorEl --- src/AppBar/AppBar.js | 4 ++-- src/DatePicker/dateUtils.js | 4 ++-- src/FloatingActionButton/FloatingActionButton.js | 2 +- src/Popover/Popover.js | 8 +------- src/RadioButton/RadioButtonGroup.js | 2 +- src/Stepper/StepContent.js | 2 +- src/Tabs/Tabs.js | 4 ++-- src/TextField/TextField.js | 2 +- src/internal/EnhancedSwitch.js | 2 +- src/utils/callOnce.js | 2 +- 10 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/AppBar/AppBar.js b/src/AppBar/AppBar.js index d1e75d11190617..55d3bf92584d7f 100644 --- a/src/AppBar/AppBar.js +++ b/src/AppBar/AppBar.js @@ -153,10 +153,10 @@ class AppBar extends Component { }; componentDidMount() { - warning(!this.props.iconElementLeft || !this.props.iconClassNameLeft, `Properties iconElementLeft + warning(!this.props.iconElementLeft || !this.props.iconClassNameLeft, `Material-UI: Properties iconElementLeft and iconClassNameLeft cannot be simultaneously defined. Please use one or the other.`); - warning(!this.props.iconElementRight || !this.props.iconClassNameRight, `Properties iconElementRight + warning(!this.props.iconElementRight || !this.props.iconClassNameRight, `Material-UI: Properties iconElementRight and iconClassNameRight cannot be simultaneously defined. Please use one or the other.`); } diff --git a/src/DatePicker/dateUtils.js b/src/DatePicker/dateUtils.js index 508880c170c067..11b2c3f908302e 100644 --- a/src/DatePicker/dateUtils.js +++ b/src/DatePicker/dateUtils.js @@ -8,7 +8,7 @@ const monthLongList = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; export function dateTimeFormat(locale, options) { - warning(locale === 'en-US', `The ${locale} locale is not supported by the built-in DateTimeFormat. + warning(locale === 'en-US', `Material-UI: The ${locale} locale is not supported by the built-in DateTimeFormat. Use the \`DateTimeFormat\` prop to supply an alternative implementation.`); this.format = function(date) { @@ -25,7 +25,7 @@ export function dateTimeFormat(locale, options) { } else if (options.day === 'numeric') { return date.getDate(); } else { - warning(false, 'Wrong usage of DateTimeFormat'); + warning(false, 'Material-UI: Wrong usage of DateTimeFormat'); } }; } diff --git a/src/FloatingActionButton/FloatingActionButton.js b/src/FloatingActionButton/FloatingActionButton.js index ebb3936af0efb8..1515f7a0489b6d 100644 --- a/src/FloatingActionButton/FloatingActionButton.js +++ b/src/FloatingActionButton/FloatingActionButton.js @@ -158,7 +158,7 @@ class FloatingActionButton extends Component { componentDidMount() { warning(!this.props.iconClassName || !this.props.children, - 'You have set both an iconClassName and a child icon. ' + + 'Material-UI: You have set both an iconClassName and a child icon. ' + 'It is recommended you use only one method when adding ' + 'icons to FloatingActionButtons.'); } diff --git a/src/Popover/Popover.js b/src/Popover/Popover.js index 4660450de54209..3e5a2722d090af 100644 --- a/src/Popover/Popover.js +++ b/src/Popover/Popover.js @@ -7,12 +7,6 @@ import Paper from '../Paper'; import throttle from 'lodash.throttle'; import PopoverAnimationDefault from './PopoverAnimationDefault'; -const styles = { - root: { - display: 'none', - }, -}; - class Popover extends Component { static propTypes = { /** @@ -383,7 +377,7 @@ class Popover extends Component { render() { return ( -
+
is only designed for use with the vertical stepper.'); + warning(false, 'Material-UI: is only designed for use with the vertical stepper.'); return null; } diff --git a/src/Tabs/Tabs.js b/src/Tabs/Tabs.js index 2131b61b68e104..bf556157b5012a 100644 --- a/src/Tabs/Tabs.js +++ b/src/Tabs/Tabs.js @@ -196,11 +196,11 @@ class Tabs extends Component { const tabs = this.getTabs().map((tab, index) => { warning(tab.type && tab.type.muiName === 'Tab', - `Tabs only accepts Tab Components as children. + `Material-UI: Tabs only accepts Tab Components as children. Found ${tab.type.muiName || tab.type} as child number ${index + 1} of Tabs`); warning(!tabValue || tab.props.value !== undefined, - `Tabs value prop has been passed, but Tab ${index} + `Material-UI: Tabs value prop has been passed, but Tab ${index} does not have a value prop. Needs value if Tabs is going to be a controlled component.`); diff --git a/src/TextField/TextField.js b/src/TextField/TextField.js index 4b41038a71a386..41e0346b6269ca 100644 --- a/src/TextField/TextField.js +++ b/src/TextField/TextField.js @@ -276,7 +276,7 @@ class TextField extends Component { hasValue: isValid(propsLeaf.value) || isValid(propsLeaf.defaultValue), }); - warning(name || hintText || floatingLabelText || id, `We don't have enough information + warning(name || hintText || floatingLabelText || id, `Material-UI: We don't have enough information to build a robust unique id for the TextField component. Please provide an id or a name.`); const uniqueId = `${name}-${hintText}-${floatingLabelText}-${ diff --git a/src/internal/EnhancedSwitch.js b/src/internal/EnhancedSwitch.js index e5bfe563c3311a..ef8203680cf332 100644 --- a/src/internal/EnhancedSwitch.js +++ b/src/internal/EnhancedSwitch.js @@ -150,7 +150,7 @@ class EnhancedSwitch extends Component { } this.refs.checkbox.checked = newSwitchedValue; } else { - warning(false, 'Cannot call set method while checked is defined as a property.'); + warning(false, 'Material-UI: Cannot call set method while checked is defined as a property.'); } } diff --git a/src/utils/callOnce.js b/src/utils/callOnce.js index bba6798e6494ad..774c0324db412f 100644 --- a/src/utils/callOnce.js +++ b/src/utils/callOnce.js @@ -6,7 +6,7 @@ export default function callOnce() { if (process.env.NODE_ENV !== 'production') { return (style) => { if (style[CALLED_ONCE]) { - warning(false, 'You cannot call prepareStyles() on the same style object more than once.'); + warning(false, 'Material-UI: You cannot call prepareStyles() on the same style object more than once.'); } style[CALLED_ONCE] = true; return style;