-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Popup): Multiple event triggering a Popup #1977
Changes from 4 commits
1cab40a
917297a
de6518d
d8ef3b3
f799471
6a8227f
883818f
b0c4c67
1354c3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { Input, Popup } from 'semantic-ui-react' | ||
|
||
const PopupExampleMultiple = () => ( | ||
<Popup | ||
trigger={<Input icon='search' placeholder='Search...' />} | ||
header='Movie Search' | ||
content='You may search by genre, header, year and actors' | ||
on={['focus', 'hover']} | ||
/> | ||
) | ||
|
||
export default PopupExampleMultiple |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ export interface PopupProps extends PortalProps { | |
offset?: number; | ||
|
||
/** Event triggering the popup. */ | ||
on?: 'hover' | 'click' | 'focus'; | ||
on?: Array<string>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** | ||
* Called when a close event happens. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ export default class Popup extends Component { | |
offset: PropTypes.number, | ||
|
||
/** Event triggering the popup. */ | ||
on: PropTypes.oneOf(['hover', 'click', 'focus']), | ||
on: PropTypes.arrayOf(PropTypes.oneOf(['hover', 'click', 'focus'])), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid propType will be: propTypes.oneOfType([
PropTypes.oneOf(['hover', 'click', 'focus']),
PropTypes.arrayOf(['hover', 'click', 'focus']),
]) |
||
|
||
/** | ||
* Called when a close event happens. | ||
|
@@ -127,7 +127,7 @@ export default class Popup extends Component { | |
|
||
static defaultProps = { | ||
position: 'top left', | ||
on: 'hover', | ||
on: ['hover'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can left this |
||
} | ||
|
||
static _meta = { | ||
|
@@ -250,15 +250,16 @@ export default class Popup extends Component { | |
portalProps.closeOnPortalMouseLeave = true | ||
portalProps.mouseLeaveDelay = 300 | ||
} | ||
|
||
if (on === 'click') { | ||
if (_.indexOf(on, 'click') > -1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can normalize value there and then use it: const normalizedOn = _.isArray(on) ? on : [on] This will allow to pass |
||
portalProps.openOnTriggerClick = true | ||
portalProps.closeOnTriggerClick = true | ||
portalProps.closeOnDocumentClick = true | ||
} else if (on === 'focus') { | ||
} | ||
if (_.indexOf(on, 'focus') > -1) { | ||
portalProps.openOnTriggerFocus = true | ||
portalProps.closeOnTriggerBlur = true | ||
} else if (on === 'hover') { | ||
} | ||
if (_.indexOf(on, 'hover') > -1) { | ||
portalProps.openOnTriggerMouseEnter = true | ||
portalProps.closeOnTriggerMouseLeave = true | ||
// Taken from SUI: https://git.io/vPmCm | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert this