Skip to content

Commit

Permalink
Merge pull request #161 from XiaoMi/hotfix/cascader-closepanel
Browse files Browse the repository at this point in the history
Hotfix/cascader closepanel
  • Loading branch information
zhan8863 authored Apr 10, 2019
2 parents db1888c + 11cc3a7 commit 353710d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build/webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const basePath = path.resolve(__dirname, '../')

module.exports = {
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = {
}
},
minimizer: [
new UglifyJsPlugin()
new TerserPlugin()
],
usedExports: true,
sideEffects: true
Expand Down
20 changes: 11 additions & 9 deletions components/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class Popover extends Component {
}
this.eventTarget = null
this.popperRef = React.createRef()
this.referenceRef = React.createRef()
// this.referenceRef = React.createRef()
}

showPopper () {
Expand All @@ -52,8 +52,9 @@ export default class Popover extends Component {

isInPopover () {
const popper = this.popperRef.current
const referenceRef = ReactDOM.findDOMNode(this.refs.referenceRef)
const bool = !this.element || this.element.contains(this.eventTarget) ||
!this.referenceRef.current || this.referenceRef.current.contains(this.eventTarget) ||
!referenceRef || referenceRef.contains(this.eventTarget) ||
!popper || popper.contains(this.eventTarget)
this.eventTarget = null
return bool
Expand All @@ -63,11 +64,12 @@ export default class Popover extends Component {
const { trigger } = this.props

this.element = ReactDOM.findDOMNode(this)
const referenceRef = ReactDOM.findDOMNode(this.refs.referenceRef)
// this.reference = ReactDOM.findDOMNode(this.refs.reference)
if (this.referenceRef.current === null) return
if (referenceRef === null) return

if (trigger === 'click') {
this.referenceRef.current.addEventListener('click', () => {
referenceRef.addEventListener('click', () => {
if (this.state.showPopper) {
this.hidePopper()
} else {
Expand All @@ -82,16 +84,16 @@ export default class Popover extends Component {
this.hidePopper()
})
} else if (trigger === 'hover') {
this.referenceRef.current.addEventListener('mouseenter', e => {
referenceRef.addEventListener('mouseenter', e => {
this.eventTarget = e.target
this.showPopper()
})
this.referenceRef.current.addEventListener('mouseleave', e => {
referenceRef.addEventListener('mouseleave', e => {
this.delayHidePopper(e)
})
} else {
this.referenceRef.current.addEventListener('focus', this.showPopper.bind(this))
this.referenceRef.current.addEventListener('blur', this.hidePopper.bind(this))
referenceRef.addEventListener('focus', this.showPopper.bind(this))
referenceRef.addEventListener('blur', this.hidePopper.bind(this))
}
}

Expand Down Expand Up @@ -119,7 +121,7 @@ export default class Popover extends Component {

return (
<div className={classNames(className, 'hi-popover')} style={style} ref={node => { this.popoverContainer = node }}>
{ React.cloneElement(React.Children.only(this.props.children), { ref: this.referenceRef, tabIndex: '0' }) }
{ React.cloneElement(React.Children.only(this.props.children), { ref: 'referenceRef', tabIndex: '0' }) }

<Popper
className='hi-popover__popper'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/hiui",
"version": "1.4.0",
"version": "1.4.1",
"description": "HIUI for React",
"scripts": {
"test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",
Expand Down Expand Up @@ -53,7 +53,6 @@
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"shallowequal": "^1.0.2",
"uglifyjs-webpack-plugin": "^2.1.1",
"warning": "^3.0.0",
"whatwg-fetch": "^2.0.4"
},
Expand Down Expand Up @@ -106,6 +105,7 @@
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-scss": "^3.4.0",
"terser-webpack-plugin": "^1.2.3",
"through2": "^2.0.3",
"url-loader": "^1.0.1",
"webpack": "^4.29.0",
Expand Down

0 comments on commit 353710d

Please sign in to comment.