Skip to content
Permalink
Browse files

Fix some component warnings (#558)

  • Loading branch information...
sohkai committed Sep 3, 2019
1 parent ef2eaaf commit d105fcf5c4607995d6024b65e526049b9284df72
Showing with 25 additions and 9 deletions.
  1. +13 −8 src/components/Button/Button.js
  2. +12 −1 src/components/Popover/Popover.js
@@ -149,19 +149,24 @@ function Button({
}) {
// backward compatibility and deprecated props
if (iconOnly) {
warnOnce('Button: "iconOnly" is deprecated, please use "display".')
warnOnce(
'Button:iconOnly',
'Button: "iconOnly" is deprecated, please use "display".'
)
display = 'icon'
}
if (mode === 'outline' || mode === 'secondary') {
warnOnce(`Button: the mode "${mode}" is deprecated, please use "normal".`)
warnOnce(
'Button:mode',
`Button: the mode "${mode}" is deprecated, please use "normal".`
)
mode = 'normal'
}
if (size === 'normal') {
warnOnce(`Button: the size "normal" is deprecated, please use "medium".`)
size = 'medium'
}
if (size === 'large') {
warnOnce(`Button: the size "large" is deprecated, please use "medium".`)
if (size === 'normal' || size === 'large') {
warnOnce(
'Button:size',
`Button: the size "${size}" is deprecated, please use "medium".`
)
size = 'medium'
}

@@ -5,7 +5,7 @@ import { Transition, animated } from 'react-spring'
import { useRoot } from '../../providers'
import { springs, RADIUS } from '../../style'
import { useTheme } from '../../theme'
import { noop, stylingProps, KEY_ESC } from '../../utils'
import { noop, stylingProps, warn, KEY_ESC } from '../../utils'
import RootPortal from '../RootPortal/RootPortal'

class PopoverBase extends React.Component {
@@ -140,6 +140,17 @@ class PopoverBase extends React.Component {
this._cardElement.current.contains(focusedElement)) ||
(closeOnOpenerFocus && opener && opener.contains(focusedElement))
) {
if (
closeOnOpenerFocus &&
(opener.tagName === 'BUTTON' || opener.tagName === 'INPUT')
) {
warn(
'Popover: using "closeOnOpenerFocus" with a <button> or <input> may lead to bugs due ' +
'to cross-environment focus event handling. ' +
'See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus ' +
'for more information.'
)
}
return
}

0 comments on commit d105fcf

Please sign in to comment.
You can’t perform that action at this time.