Skip to content
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

fix(Popup): fix issue with open prop #3020

Closed
wants to merge 4 commits into from

Conversation

msrikanth508
Copy link
Contributor

@msrikanth508 msrikanth508 commented Jul 18, 2018

Issue: After rendering trigger prop there is no way to calculate popup position styles, hence it is rendering somewhere in the DOM
Fix: Calling setPopupStyle func in trigger handler to calculate popup positions based on trigger prop element

Fixes #2991.

@codecov-io
Copy link

codecov-io commented Jul 18, 2018

Codecov Report

Merging #3020 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3020      +/-   ##
==========================================
+ Coverage   99.92%   99.96%   +0.03%     
==========================================
  Files         169      163       -6     
  Lines        2802     2745      -57     
==========================================
- Hits         2800     2744      -56     
+ Misses          2        1       -1
Impacted Files Coverage Δ
src/modules/Popup/Popup.js 100% <100%> (ø) ⬆️
src/modules/Transition/TransitionGroup.js 100% <0%> (ø) ⬆️
src/modules/Accordion/AccordionAccordion.js 100% <0%> (ø) ⬆️
src/modules/Sidebar/Sidebar.js 100% <0%> (ø) ⬆️
src/elements/Image/Image.js 100% <0%> (ø) ⬆️
src/collections/Grid/GridColumn.js 100% <0%> (ø) ⬆️
src/modules/Sticky/Sticky.js 100% <0%> (ø) ⬆️
src/modules/Rating/RatingIcon.js 100% <0%> (ø) ⬆️
src/elements/Segment/Segment.js 100% <0%> (ø) ⬆️
... and 10 more

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 10219af...9af49d2. Read the comment docs.

@layershifter layershifter changed the title fix(popup): Fixed popup open prop issue #2991 fix(Popup): fix issue with open prop Jul 19, 2018
Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

This PR is made from msrikanth508:master so I cannot push fixes. I will branch from it, make the udpates I've noted and probably make a release soon.

// then set popup coordinates when triggerref is available
if (_.has(this.props, 'open')) {
this.setPopupStyle()
}
Copy link
Member

Choose a reason for hiding this comment

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

Should this not only be set if open is truthy? Also, let's link the issue here in the code:

handleTriggerRef = (triggerRef) => {
  const { open } = this.props
  // ...

  // https://github.com/Semantic-Org/Semantic-UI-React/issues/2991
  if (open) this.setPopupStyle()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and we should also add open in propTypes list.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, we have some work to do in regard to inherited props #1169.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand inherited props. In popup.d.ts file we are already inheriting from PortalProps.

// element.style.should.have.property('top', '')
// element.style.should.have.property('left', '')
// element.style.should.have.property('bottom', '')
// element.style.should.have.property('right', '')
Copy link
Member

Choose a reason for hiding this comment

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

Let's cleanup cruft.

expect(top).to.not.equal('')
expect(left).to.not.equal('')
expect(bottom).to.not.equal('')
expect(right).to.not.equal('')
Copy link
Member

Choose a reason for hiding this comment

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

Would be ideal if these made more specific assertions about where it should be positioned opposed to where it should not be positioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new assertion expect(element.parentNode).to.equal(document.body)

@levithomason
Copy link
Member

It seems there are some deeper issues here with InnerPortal and ReactDOM.createPortal. See #3029.

@levithomason
Copy link
Member

I should also note, the tests here are passing but the feature is not working.

@msrikanth508
Copy link
Contributor Author

@levithomason I've fixed code review comments. Here is the working example

1. Default open prop

<Popup trigger={<Button >Opened</Button>} open >test</Popup>

2. Change status dynamically

class Example extends React.Component {
  state ={
    open: false,
  }
  componentDidMount() {
    setTimeout(() => {
      this.setState({
        open: true,
      })
    }, 5000)
  }
  render() {
    return (
      <Container id='introduction-page' style={{ paddingTop: 100 }}>
        <Popup trigger={<Button >Opened</Button>} open={this.state.open} >test</Popup>
      </Container>
    )
  }
}

I'm facing one issue though, I'm trying to create an example in docs with open prop but it's not working. Need your help here.

@levithomason
Copy link
Member

I'm facing one issue though, I'm trying to create an example in docs with open prop but it's not working. Need your help here.

This is the same issue I was having. I'll have to come back to this one and do some digging.

@msrikanth508
Copy link
Contributor Author

@levithomason Did you get a chance to look into this?

@levithomason
Copy link
Member

I did not, apologies for the delays. It is on my higher priority list, along with the Dropdown issues we've had recently. Working on these a bit today as well.

@layershifter layershifter mentioned this pull request Aug 22, 2018
@fc
Copy link

fc commented Sep 10, 2018

What's the status on this? @levithomason

@fc
Copy link

fc commented Sep 11, 2018

For those who need this functionality, this is a regression and if you rollback to this version it'll work: semantic-ui-react@0.81.1

@levithomason
Copy link
Member

This needs tested in a browser to ensure it is working as expected. Last I pulled this fork and updated one of the examples to have <Popup open />, the Popup was still incorrectly positioned in the upper right of the body.

Are there any others who are getting the correct results from this PR?

@levithomason
Copy link
Member

@msrikanth508 any chance you can change the base branch here from your master to another branch? That way the maintainers can push changes to it. We don't have rights to PRs from master branches, only other branches.

@layershifter
Copy link
Member

I've reached some progress in #3029
We should check why tests are broken, manual test was passed.

@msrikanth508
Copy link
Contributor Author

@levithomason I've created new branch from my commits.
https://github.com/msrikanth508/Semantic-UI-React/tree/fix/pop-up

@layershifter
Copy link
Member

Fixed in #3029.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants