Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Popup): add 'target' prop #356

Merged
merged 5 commits into from
Oct 15, 2018
Merged

feat(Popup): add 'target' prop #356

merged 5 commits into from
Oct 15, 2018

Conversation

kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Oct 12, 2018

TODO

  • update CHANGELOG

API changes

Target

Accepts DOM element that will be used as popup's target (instead of trigger element that is used by default). This prop will also allow to support 'bridge' scenarios, where it is necessary for client to display a popup for some DOM element that is not managed by React.

/* popup will be triggered by button, but displayed for 'domElement' */
<Popup 
  target={domElement} 
  trigger={<Button ... />} 
/>

This is an optional prop - if omitted (by default) Popup will still use trigger element as a target.

/* popup will be triggered and displayed for button */
<Popup 
  trigger={<Button ... />} 
/>

@codecov
Copy link

codecov bot commented Oct 12, 2018

Codecov Report

Merging #356 into master will decrease coverage by 0.34%.
The diff coverage is 18.75%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #356      +/-   ##
=========================================
- Coverage   89.75%   89.4%   -0.35%     
=========================================
  Files          64      64              
  Lines        1259    1265       +6     
  Branches      182     163      -19     
=========================================
+ Hits         1130    1131       +1     
- Misses        126     131       +5     
  Partials        3       3
Impacted Files Coverage Δ
src/components/Ref/Ref.tsx 100% <100%> (ø) ⬆️
src/components/Popup/Popup.tsx 39.06% <13.33%> (-2.32%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94d8291...c777daf. Read the comment docs.

Copy link
Collaborator

@bmdalex bmdalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@@ -34,6 +34,6 @@ export default class Ref extends Component<IRefProps> {
}

render() {
return Children.only(this.props.children)
return this.props.children && Children.only(this.props.children)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise, in case if children is not provided for the component, this will throw the error and fails rendering process for the whole tree - while, in contrast, if we will handle it this way, then for innerRef callback null will be validly provided as captured DOM element (as there are no elements rendered)

@kuzhelov kuzhelov merged commit 6713038 into master Oct 15, 2018
@layershifter layershifter deleted the feat/popup-add-target-prop branch November 9, 2018 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants