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(Responsive): use root element client width #2531

Merged
merged 5 commits into from
Feb 25, 2018
Merged

fix(Responsive): use root element client width #2531

merged 5 commits into from
Feb 25, 2018

Conversation

autarc
Copy link
Contributor

@autarc autarc commented Feb 16, 2018

There is currently an issue with the Responsive component regarding the expected rendering behavior. While the element should render if it's visible the fitsMinWidth and fitsMaxWidth can return miss matches depending on the state of mobile devices. Zooming on webkit based browser at iOS (mobile Safari, Google Chrome) triggers the resize event at which window.innerWidth returns an incorrect value.

By using the measurements of the root element of the document (document.documentElement) rather than the window viewport the detection is more reliable. Instead of capturing the modified width during gestures like pinch to zoom the actual one of the document will be used.

@welcome
Copy link

welcome bot commented Feb 16, 2018

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@codecov-io
Copy link

codecov-io commented Feb 16, 2018

Codecov Report

Merging #2531 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2531      +/-   ##
==========================================
- Coverage   99.74%   99.74%   -0.01%     
==========================================
  Files         160      154       -6     
  Lines        2744     2712      -32     
==========================================
- Hits         2737     2705      -32     
  Misses          7        7
Impacted Files Coverage Δ
src/addons/Responsive/Responsive.js 100% <100%> (ø) ⬆️
src/modules/Dropdown/Dropdown.js 100% <0%> (ø) ⬆️
src/modules/Dropdown/DropdownMenu.js 100% <0%> (ø) ⬆️
src/modules/Modal/Modal.js 100% <0%> (ø) ⬆️
src/addons/MountNode/lib/handleClassNamesChange.js
src/addons/MountNode/lib/computeClassNames.js
...ddons/MountNode/lib/computeClassNamesDifference.js
src/addons/MountNode/lib/NodeRegistry.js
src/addons/MountNode/MountNode.js
src/addons/MountNode/lib/getNodeFromProps.js

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 8e13323...181095b. Read the comment docs.

@levithomason
Copy link
Member

levithomason commented Feb 18, 2018

I wish we had mobile tests :) Thanks for the investigation and contribution.

@@ -60,7 +60,7 @@ export default class Responsive extends Component {
constructor(...args) {
super(...args)

this.state = { width: isBrowser() ? window.innerWidth : 0 }
this.state = { width: isBrowser() ? document.documentElement.clientWidth : 0 }
Copy link
Member

Choose a reason for hiding this comment

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

This is probably worth adding an inline comment with the GitHub issue URL and a one-line description as to why this is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay added a comment and reference to the PR. Will be squashed if it's fine :)

@levithomason levithomason merged commit cbc1a39 into Semantic-Org:master Feb 25, 2018
@welcome
Copy link

welcome bot commented Feb 25, 2018

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

@levithomason
Copy link
Member

Released in semantic-ui-react@0.78.3.

Brantron pushed a commit to Brantron/Semantic-UI-React that referenced this pull request Mar 14, 2018
* fix(Responsive): use root element client width

* Add PR reference
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