react-use icon indicating copy to clipboard operation
react-use copied to clipboard

fix: useMeasure top/left/y/x values were always zero

Open tomasdisk opened this issue 3 years ago ā€¢ 6 comments

Description

Fix for this issue

x, y, top and left are always 0 inside contentRect

Replace the usage of ResizeObserverEntry.contentRect, and retrive values from ResizeObserverEntry.target.getBoundingClientRect() https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • [x] Read the Contributing Guide
  • [x] Perform a code self-review
  • [ ] Comment the code, particularly in hard-to-understand areas
  • [ ] Add documentation
  • [ ] Add hook's story at Storybook
  • [x] Cover changes with tests
  • [x] Ensure the test suite passes (yarn test)
  • [x] Provide 100% tests coverage
  • [ ] Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • [x] Make sure types are fine (yarn lint:types).

tomasdisk avatar Jun 03 '21 19:06 tomasdisk

Any chance to get this merged? Facing the same issue

madeleineostoja avatar Jul 20 '21 23:07 madeleineostoja

Any news yet on when this will be merged, please? It's been over a year since the PR was submitted.

danielvanc avatar Jun 22 '22 14:06 danielvanc

Unfortunately this repository ain't being maintained by its owner. I think this will never merge šŸ˜¢

tomasdisk avatar Jun 22 '22 18:06 tomasdisk

@tomasdisk It doesn't look promising, however, it looks like there has been activity within the last month or so, if you look at the commit history.

danielvanc avatar Jun 27 '22 09:06 danielvanc

Any news? I think this is more helpful than contentRect @streamich

contentRect does not calculate border and padding, based on MDN

cangSDARM avatar Sep 02 '22 10:09 cangSDARM

I confirmed locally that the fix in this PR works. Could you consider merging it, @streamich? Iā€™m willing to help where I can, if any help is welcomed.

lensbart avatar Oct 16 '22 13:10 lensbart

Any news about this PR ? I think it would be really helpful @streamich

nleborgne avatar Feb 21 '23 15:02 nleborgne

@nleborgne you may be interested to take a look at the better-maintained (yet awkwardly-named) https://github.com/react-hookz/web library. This one seems to be ignored by its author.

lensbart avatar Feb 21 '23 15:02 lensbart

@nleborgne you may be interested to take a look at the better-maintained (yet awkwardly-named) https://github.com/react-hookz/web library. This one seems to be ignored by its author.

Thanks, I gave a quick look at the repo, it seems like the useMeasure hook only returns the width and height in the Measure object. Is there any way to access properties like top and left like in the react-use useMeasure hook?

nleborgne avatar Feb 23 '23 14:02 nleborgne