victory icon indicating copy to clipboard operation
victory copied to clipboard

[WIP] fix(#2108) get label text size from dom rendering

Open camray opened this issue 3 years ago • 1 comments

Fixes #2108

Uses DOM measurements for label width and height. This method proves to be more accurate and 27% more performant than the existing approximation solution as shown below, particularly for CJK and RTL languages.

Some technical limitations include:

  • Lack of support for SSR & React Native
    • The window element does not exist for either so we continue to fall back to the approximation solution.
    • It would be very helpful to get a React Native developer to add a similar solution that will work on mobile.
  • Testing is difficult and non-comprehensive
    • Since jsdom doesn't actually render and there is no window width/height, it cannot be measured in tests.
    • I would love to hear solutions to this problem if any exist. Currently I'm testing that the element is added to the dom.
Screen Shot 2022-07-06 at 11 04 10 AM Screen Shot 2022-07-06 at 11 03 08 AM Screen Shot 2022-07-06 at 11 02 50 AM

camray avatar Jul 06 '22 15:07 camray

Feel free to resolve my comments as you wish!

scottrippey avatar Jul 14 '22 22:07 scottrippey