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

ResizeObserver: Use contentBoxSize #2882

Merged
merged 10 commits into from
Apr 6, 2022
Merged

ResizeObserver: Use contentBoxSize #2882

merged 10 commits into from
Apr 6, 2022

Conversation

amanmahajan7
Copy link
Contributor

@amanmahajan7 amanmahajan7 commented Apr 6, 2022

FF bug is fixed in 99. We can wait for a few weeks before merging this PR to give everyone some time

@amanmahajan7 amanmahajan7 self-assigned this Apr 6, 2022

saveDimensions();
const resizeObserver = new ResizeObserver(saveDimensions);
setInlineSize(size.inlineSize - (devicePixelRatio % 1 === 0 ? 0 : 1));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we are using inlineSize/blockSize, RDG is one step closer to handling writing mode
https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentBoxSize#value

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check that these values are the same as clientWidth/clientHeight?
Something like

if (clientWidth !== inlineSize || clientHeight !== blockSize) {
  throw new Error('🤔');
}

Just to make sure, not to be commited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we can give it a try, but I'm worried about decimal values leading to more shaky grids.

Copy link
Contributor Author

@amanmahajan7 amanmahajan7 Apr 6, 2022

Choose a reason for hiding this comment

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

If we have a reproducible bug example then we can test it

src/hooks/useGridDimensions.ts Show resolved Hide resolved
@amanmahajan7 amanmahajan7 marked this pull request as ready for review April 6, 2022 16:55
@amanmahajan7 amanmahajan7 requested a review from nstepien as a code owner April 6, 2022 16:55
@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #2882 (046475c) into main (fa2f98d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2882      +/-   ##
==========================================
+ Coverage   96.22%   96.24%   +0.01%     
==========================================
  Files          38       38              
  Lines        1244     1250       +6     
  Branches      391      391              
==========================================
+ Hits         1197     1203       +6     
  Misses         47       47              
Impacted Files Coverage Δ
src/hooks/useGridDimensions.ts 100.00% <100.00%> (ø)
src/utils/index.ts 88.88% <100.00%> (ø)

src/hooks/useGridDimensions.ts Outdated Show resolved Hide resolved
this.callback([], this);
// patch inlineSize/blockSize to pretend we're rendering DataGrid at 1920p/1080p
// @ts-expect-error
this.callback([{ contentBoxSize: [{ inlineSize: 1920, blockSize: 1080 }] }], this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the clientWidth/clientHeight patch below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still needed. We can also change the window.ResizeObserver to not call callback

src/hooks/useGridDimensions.ts Outdated Show resolved Hide resolved
@amanmahajan7 amanmahajan7 requested a review from nstepien April 6, 2022 18:08
@amanmahajan7 amanmahajan7 merged commit 625fad5 into main Apr 6, 2022
@amanmahajan7 amanmahajan7 deleted the am-resize-observer branch April 6, 2022 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants