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): use original position if none fit in viewport #1483

Merged
merged 3 commits into from
Jul 29, 2017

Conversation

MindFreeze
Copy link
Contributor

@MindFreeze MindFreeze commented Mar 20, 2017

Should fix #1482

@MindFreeze
Copy link
Contributor Author

I have no idea why the is always within the viewport test fails with this change. Some help with this would be appreciated.

@@ -228,7 +228,7 @@ export default class Popup extends Component {

// Lets detect if the popup is out of the viewport and adjust
// the position accordingly
const positions = _.without(POSITIONS, position)
const positions = _.without(POSITIONS, position).push(position)
Copy link
Member

Choose a reason for hiding this comment

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

This line doesn't make sense, you remove position from array and then push it again 😕

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 add it to the end of the array, so that if no suitable position can be found, the selected (last) one is used. Otherwise it would just use the last one in POSITIONS, which is bottom center.

@levithomason
Copy link
Member

@MindFreeze any interest in pushing this one over the finish line? I'd be OK merging it if tests were fixed and a new test added that asserts the new behavior. Namely, we'd need a test that says if no other position fits in the viewport then the original position is used.

Since this is a very rare edge case, it probably will not get attention from the core team.

@MindFreeze
Copy link
Contributor Author

I'll give it a go

@codecov-io
Copy link

codecov-io commented Jul 25, 2017

Codecov Report

Merging #1483 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1483   +/-   ##
=======================================
  Coverage   99.74%   99.74%           
=======================================
  Files         141      141           
  Lines        2371     2371           
=======================================
  Hits         2365     2365           
  Misses          6        6
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 3fd65da...ba7c29c. Read the comment docs.

@MindFreeze
Copy link
Contributor Author

@levithomason All done.

@levithomason
Copy link
Member

You're awesome, thanks much!

@levithomason levithomason changed the title Fix for popup position; fixes #1482 fix(Popup): use original position if none fit in viewport Jul 29, 2017
@levithomason levithomason merged commit 0ae237c into Semantic-Org:master Jul 29, 2017
@levithomason
Copy link
Member

Released in semantic-ui-react@0.71.3

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.

Popup position is not respected when near corner of window
4 participants