fitty icon indicating copy to clipboard operation
fitty copied to clipboard

oldValue and newValue are NaN

Open MatteoCampinoti94 opened this issue 2 years ago • 8 comments

Hi, I'm having this weird issue with fitty.

I have the following HTML structure: Screenshot 2022-01-19 at 11 27 53

And I'm using muicss together with this simple stylesheet: Screenshot 2022-01-19 at 11 19 35

And then at the end of the body, I import fitty via jsdelivr and initialise it with the right elements: Screenshot 2022-01-19 at 11 15 08

(The updateBadge function uses the form fields to change the innerText of the .example elements, but otherwise doesn't modify them)

The fit event triggers correctly on content change, but it doesn't actually update the font size. It doesn't even seem to get the current font size. Here is the log output of the fit event: Screenshot 2022-01-19 at 11 17 48 Screenshot 2022-01-19 at 11 17 55

The first event is when fitty is initialised, the second when the event triggers from a content change. As you can see it cannot compute the new value, and even the current is a NaN after the first event.

I tried everything I can think of, including removing all styles (with the exception of no-wrap and inline-block).

MatteoCampinoti94 avatar Jan 19 '22 10:01 MatteoCampinoti94

can you create a public test case for this?

rikschennink avatar Jan 20 '22 08:01 rikschennink

Here is the index file (minus the backend template parts). The actual web app has already been updated with a different method so no online test alas :/

GitHub doesn't allow HTML extensions, so I had to change it to txt index.txt.

MatteoCampinoti94 avatar Jan 20 '22 08:01 MatteoCampinoti94

It would be easiest if you can create a reproduction on codesandbox.io

rikschennink avatar Jan 20 '22 09:01 rikschennink

Here it is https://codesandbox.io/s/fitty-test-29ksf

Didn't know about that website, thanks for the suggestion!

MatteoCampinoti94 avatar Jan 20 '22 10:01 MatteoCampinoti94

It throws an "Cannot import an empty path" error, not sure what I should be looking at?

rikschennink avatar Jan 21 '22 07:01 rikschennink

Fixed it. It's a codesandbox error, apparently it doesn't like empty src attributes. To see the error just enter values in the username and label fields. The example tags update the content correctly, but the fit events cannot determine their font size.

MatteoCampinoti94 avatar Jan 21 '22 08:01 MatteoCampinoti94

Tried to find the issue but wasn't successful.

I'd restart with a basic page and then work my way from there to find at what point the calculations go wrong.

rikschennink avatar Jan 24 '22 08:01 rikschennink

Will try 👍

MatteoCampinoti94 avatar Jan 24 '22 09:01 MatteoCampinoti94