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) popup appearing in wrong position when open prop is set #2775

Merged
merged 5 commits into from
May 19, 2018

Conversation

cdaringe
Copy link
Contributor

@cdaringe cdaringe commented May 8, 2018

problem

solution

  • add in RAF behavior per @levithomason's recommendation.
    • i didn't actually properly animate it in, but this still has the added benefit of keeping the <Popup /> correctly attached to the trigger if the trigger moves

demo

here i use <Popup /> for form validation.

with fix, the <Popup /> immediately renders when the field is dirty and empty:

good mov

without fix. the <Popup /> is out of the viewport. I have to fidget with the trigger={<Input />} to get the Popup to eventually appear where it has been commanded to go:

bad mov

@cdaringe cdaringe changed the title Popup open prop fix fix(Popup) popup appearing in wrong position when open prop is set May 8, 2018
@codecov-io
Copy link

codecov-io commented May 8, 2018

Codecov Report

Merging #2775 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2775      +/-   ##
==========================================
+ Coverage   99.74%   99.74%   +<.01%     
==========================================
  Files         160      160              
  Lines        2762     2771       +9     
==========================================
+ Hits         2755     2764       +9     
  Misses          7        7
Impacted Files Coverage Δ
src/modules/Popup/Popup.js 100% <100%> (ø) ⬆️

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 447f96b...02ff41f. Read the comment docs.

@cdaringe cdaringe force-pushed the popup-open-prop-fix branch from 866bb3c to c822956 Compare May 8, 2018 19:44
this.setPopupStyle(this.props.position)
}

this.animationRequestId = requestAnimationFrame(this.setPosition)
Copy link
Member

Choose a reason for hiding this comment

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

haven't you introduced an infinite loop now? When does this ever get short circuited?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. fixed in 7c2104f

Choose a reason for hiding this comment

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

Unfortunately the infinite loop is still there - all the time the popup is displayed setPosition() is called in a loop, it then calls setPopupStyle which re-sets component's state which causes re-render - takes ~20% CPU when the popup is displayed.

@cdaringe
Copy link
Contributor Author

hi all, kind and cordial bump!

@levithomason
Copy link
Member

Such a gentleman 😉 reviewing!

@levithomason
Copy link
Member

Just merged master, we can ship this once tests pass again.

@cdaringe
Copy link
Contributor Author

codecov seems to be all hung up!

@levithomason levithomason merged commit 4f82da4 into Semantic-Org:master May 19, 2018
@welcome
Copy link

welcome bot commented May 19, 2018

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

@levithomason
Copy link
Member

Released in semantic-ui-react@0.80.1.

@cdaringe
Copy link
Contributor Author

nice! ps, if you havent seen already, the latest version of semantic-release auto posts back into PRs what versions PRs get released in. so great!

@aminland
Copy link

With this commit, scrolling the window causes very strange behavior.

semantic-ui-popup-bug

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.

6 participants