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

Handle custom fonts loading #362

Merged
merged 6 commits into from
Mar 21, 2023

Conversation

ArnaudRinquin
Copy link
Contributor

We had an issue using this library with a custom font for the textarea. It turns out the initial resizing could be done before the font is loaded.

This PR brings both the fix for it and adds such a case in the examples.

The fix is rather simple: listen for fonts being loaded, the same way we listen for the window being resized, and resize when it is done.

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2023

🦋 Changeset detected

Latest commit: 93acf2e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-textarea-autosize Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

src/hooks.ts Outdated Show resolved Hide resolved
src/hooks.ts Outdated Show resolved Hide resolved
src/index.tsx Show resolved Hide resolved
@ArnaudRinquin
Copy link
Contributor Author

ArnaudRinquin commented Feb 6, 2023

Thanks @Andarist for the review. I tried using the code you provided but it isn't valid in the project's TS version (^3.9.3).

Switching TS version in the TS playground link you provided reveals it:
Screenshot 2023-02-06 at 15 36 31

It works if you select TS 4.4+ and forward.

Should we bump needed TS version or change the code somehow?

The latest commit I pushed should break CI as I commited with disabled hooks.

@Andarist
Copy link
Owner

Andarist commented Feb 7, 2023

I think that it's fine to bump the TS version used by the repository. It won't actually have any effect on public consumers as those particular types are only relevant internally.

@ArnaudRinquin
Copy link
Contributor Author

@Andarist I upgraded the dev dependencies, eslint, babel and prettier along TS to make the whole setup work.

@Andarist
Copy link
Owner

Andarist commented Feb 9, 2023

It seems that Babel is not happy about this syntax (CI failed) - I think that it should handle this by now though. Could you recheck what is happening?

@ArnaudRinquin
Copy link
Contributor Author

Damn, I will.

@ArnaudRinquin
Copy link
Contributor Author

@Andarist I'm not to happy with the shenanigans I had to go through to get the tests pass: adding JSDom + mocking the listeners. It doesn't really hurt but it's not crazy elegant either.

@ArnaudRinquin
Copy link
Contributor Author

Hey @Andarist do you see any blockers for this PR? Happy to adjust

@Andarist Andarist merged commit 2301195 into Andarist:main Mar 21, 2023
@github-actions github-actions bot mentioned this pull request Mar 21, 2023
@ArnaudRinquin ArnaudRinquin deleted the handle-custom-fonts-loading branch March 22, 2023 08:08
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