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: ClientRect/DOMRect is not IE11 compatible #855

Merged
merged 3 commits into from May 10, 2019

Conversation

cpboyd
Copy link
Contributor

@cpboyd cpboyd commented May 7, 2019

Fixes #853.

@moog16 I copied the usage from ripple and tab-bar so that it'd be easier to do a find & replace in the future.

Let me know if there's anything else I need to do.

@codecov-io
Copy link

codecov-io commented May 7, 2019

Codecov Report

Merging #855 into master will decrease coverage by 0.18%.
The diff coverage is 25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #855      +/-   ##
==========================================
- Coverage    94.5%   94.32%   -0.19%     
==========================================
  Files          85       85              
  Lines        3496     3505       +9     
  Branches      532      531       -1     
==========================================
+ Hits         3304     3306       +2     
- Misses         66       74       +8     
+ Partials      126      125       -1
Impacted Files Coverage Δ
packages/tab-indicator/index.tsx 88.4% <0%> (-2.64%) ⬇️
packages/chips/Chip.tsx 88.99% <0%> (-3.4%) ⬇️
packages/tab-scroller/index.tsx 90.38% <57.14%> (-0.71%) ⬇️

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 ac7e184...07e3451. Read the comment docs.

computeScrollAreaClientRect: () => {
if (!this.areaElement.current) {
// new DOMRect is not IE11 compatible
const defaultDOMRect = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make this a variable that both computeScrollAreaClientRect and computeScrollContentClientRect reference, instead of defining it twice?

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 created a function getBoundingClientRectOf within tab-scroller.

I considered a shared variable (either within the class or the adapter) but if code happened to modify the returned object, then it would result in these functions no longer returning the expected default object.

Copy link
Contributor

@moog16 moog16 left a comment

Choose a reason for hiding this comment

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

One comment, but looks good to me!

return this.chipElement.getBoundingClientRect();
},
getCheckmarkBoundingClientRect: () => {
const {chipCheckmark} = this.props;
if (!chipCheckmark) return new ClientRect();
if (!chipCheckmark) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@moog16 Should this if also check chipCheckmark.props.getBoundingClientRect?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that doesn't hurt to have the check there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I won't merge it if you want to update this...you may also want to check unit tests.

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 commit.

Couldn't run tests due to fsevents failing to build on Node v12 on Mac.

I'll try to see about switching to nvm tomorrow and running the tests.

computeHorizontalScrollbarHeight: () =>
computeHorizontalScrollbarHeight(document),
};
}

getBoundingClientRectOf = (element: HTMLElement) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good.

@cpboyd
Copy link
Contributor Author

cpboyd commented May 10, 2019

@moog16 The new commit fixed the unit tests.

Let me know if you want me to rebase these changes down to a single commit.

@moog16 moog16 changed the base branch from master to rc0.13.0 May 10, 2019 16:38
@moog16 moog16 merged commit c08b2a7 into material-components:rc0.13.0 May 10, 2019
@moog16 moog16 mentioned this pull request May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants