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

breaking(Modal): Fix vertical position with SUI 2.3 #2690

Merged
merged 9 commits into from
Apr 16, 2018
Merged

breaking(Modal): Fix vertical position with SUI 2.3 #2690

merged 9 commits into from
Apr 16, 2018

Conversation

brianespinosa
Copy link
Member

@brianespinosa brianespinosa commented Mar 28, 2018

This is part of the work for #2550. There are a few things here to look at.

  1. Modal now has a centered prop that can be set to false which positions the modal to the top of the viewport instead of the center. The default centered modal follows the same logic as SUI.
  2. Modal now renders in a flexbox wrapper the same way SUI does with modals, and no longer applies negative top margin divided by height. The logic for this calculation was left commented out since we may have to support legacy browsers... inline comment about this in the code with link for reference.
  3. Portal had to get updated to also pass style prop to the portal that we create. This means we have to manually convert a style object to a CSS string since we are creating the portal with vanilla JS. Instead of taking the time to try to handle all cases here manually, I added a minimal package that does only this.

There may be more to do but I at least wanted to get this up so we could get some eyes on it. I think we may be able to ship out an update that moves us for supporting 2.3.x soon after this one.

@brianespinosa
Copy link
Member Author

Ran out of time tonight to update the tests. Will try to get some eyes on them early tomorrow... but I likely will not have time to get back in on them until the evening.

@codecov-io
Copy link

codecov-io commented Mar 28, 2018

Codecov Report

Merging #2690 into next will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #2690      +/-   ##
==========================================
+ Coverage   99.67%   99.67%   +<.01%     
==========================================
  Files         161      161              
  Lines        2762     2769       +7     
==========================================
+ Hits         2753     2760       +7     
  Misses          9        9
Impacted Files Coverage Δ
src/modules/Modal/Modal.js 100% <100%> (ø) ⬆️
src/addons/Portal/Portal.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 4a90965...ffb7e25. Read the comment docs.


this.mountPortal()

// Server side rendering
if (!isBrowser()) return null

this.rootNode.className = className || ''
this.rootNode.style = style ? toInlineStyle(style) : ''
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

We also no longer need this external library based on the refactor requested below.

@@ -364,6 +372,7 @@ class Modal extends Component {
onMount={this.handlePortalMount}
onOpen={this.handleOpen}
onUnmount={this.handlePortalUnmount}
style={{ display: 'flex !important' }}
Copy link
Member

Choose a reason for hiding this comment

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

I see a problem there, React doesn't support important keyword for inline styles, see facebook/react#1881. Take a look on Dimmer's PR #2656 for a workaround.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. I guess it is working in this case because this is being applied to a rootNode of a portal. Or possibly because the toInlineStyle package is handling it. I'll take a look today.

Copy link
Member Author

Choose a reason for hiding this comment

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

@layershifter Updated. Technically it was working because we were passing those attributes as a string. This will keep the semantics the same way as we are handling this use case in Dimmer.


this.mountPortal()

// Server side rendering
if (!isBrowser()) return null

this.rootNode.className = className || ''
this.rootNode.style = style || ''
Copy link
Member

Choose a reason for hiding this comment

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

I think this is susceptible to users passing style objects to the <Portal style={...} />. Let me know if I'm misreading here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@levithomason correct. It is. Is there a reason you see that we should not allow that? If we do not want to allow that, is there another way you would prefer we do this?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think I was tripping out that day... Apologies, continue!

@levithomason
Copy link
Member

@layershifter @brianespinosa this looks good to me. Please merge at will if you are good with it 👍

@layershifter layershifter merged commit b3d8eda into Semantic-Org:next Apr 16, 2018
levithomason pushed a commit that referenced this pull request May 31, 2018
* chore(package): update SUI to 2.3

* feat(Dimmer): update SUI to 2.3, add verticalAlign (#2656)

* feat(Transition): update SUI to 2.3, add `zoom` and `glow` (#2658)

* feat(Icon): update SUI to 2.3 (#2665)

* breaking(Modal): Fix vertical position with SUI 2.3 (#2690)

* Update SUI css to 2.3.1

* Disable negative top margin calc

* Add the ability to apply inline styles to Portal

* Top Aligned modal example

* Make sure we are not overriding the top margin inline

* type defs updated for Portal

* Type update for Modal

* Refactor to use setProperty instead of string for important

* Remove inline-style lib to handle string differently

* chore(gulp): remove task with icons

* feat(Icon): regenerate icons

* docs(Usage): add warning about SUIR versions

* docs(README): remove note

* fix lint error

* fix(iconSearch): dedupe merged name sets
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.

4 participants