Giter Club home page Giter Club logo

Comments (4)

cee-chen avatar cee-chen commented on June 17, 2024 1

I'm going to go ahead and close this as a wontfix as this isn't an issue with EUI itself but rather a third party dependency (jsdom), and a workaround exists (see above code snippet).

from eui.

cee-chen avatar cee-chen commented on June 17, 2024

@mbondyra I'm actually not able to reproduce this on either local EUI or in a CodeSandbox 😕

Are you seeing the error in https://codesandbox.io/p/sandbox/white-mountain-3pypwc?file=%2Fdemo.js

? I tested in both Firefox and Chrome and no NaN error appeared in the dev console.

from eui.

cee-chen avatar cee-chen commented on June 17, 2024

OH sorry - I missed the part where this affects tests 🙈 This is likely a jsdom issue (e.g., DOM elements not actually having heights etc) that will need to be worked around/polyfilled in a local Jest test setup.

I'll poke around a bit more to confirm what's needed to get this working, but it's possible this may not be something EUI will fix in production/source code.

from eui.

cee-chen avatar cee-chen commented on June 17, 2024

The missing jsdom property appears to be window.getComputedStyle and it only appears to occur on rerender - see jsdom/jsdom#2986 🥲

The NaN generated comes from these lines specifically:

const computedStyles = window.getComputedStyle(cellRef, null);
const lineHeight = parseInt(computedStyles.lineHeight, 10);

I could add an IS_JEST_ENVIRONMENT check to our internal calculateHeightForLineCount logic, but that feels kinda bad when our dynamic line height logic/tests work right now in Jest without a workaround. Maybe we should wait for jsdom to fix the issue on their end? 😬

@mbondyra For your use case with a useEffect rerender, I think I lean towards asking y'all to polyfill window.getComputedStyle instead. Can you try something like:

  jest
    .spyOn(window, 'getComputedStyle')
    .mockImplementation(() => ({ lineHeight: '16px' } as any));

from eui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.