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

Allows customizing the textarea component used #235

Merged
merged 1 commit into from Apr 26, 2020
Merged

Allows customizing the textarea component used #235

merged 1 commit into from Apr 26, 2020

Conversation

vitorqb
Copy link
Contributor

@vitorqb vitorqb commented Apr 22, 2020

Hi!

I'm trying to use your library using ClojureScript and Reagent. I have hit a simple yet annoying problem.

The Reagent library (which is a wrapper around React for cljs) needs to take special care with textarea components. It has to do with async rendering and caret positioning, and I won't go into details*. Long story short: for using your library I simply need to be able to use a custom textarea component.

I'm aware that this is a quite "specific" need, but it would make the library usable for anyone using reagent and maybe you can even think on other use cases for having a custom textarea component.

I could make it work with this quite simple changes that are in this PR. I wanted to ask you if you would be willing to accept those changes (I can add it to the docs and whatever change you may want).

Thanks!

*if you are curious, see madvas/cljs-react-material-ui#17 and reagent-project/reagent#265 (comment)

@n1ru4l
Copy link
Contributor

n1ru4l commented Apr 22, 2020

This could also be the solution for allowing to implement #232 in user-land.

@andrerpena
Copy link
Owner

I think it does make sense. Thank you for your contribution!

@andrerpena andrerpena merged commit 64e8577 into andrerpena:master Apr 26, 2020
@andrerpena
Copy link
Owner

This PR had 2 problems
1 - The type of the new textarea was wrong. React.ReactNode is not a component, it is the result of React.createElement. Components are represented as React.ClassType. Also, the component props have to be a subset of HTMLTextAreaElement, so the correct type would be...

  textAreaComponent?: React.ClassType<
    Partial<
      DetailedHTMLFactory<
        TextareaHTMLAttributes<HTMLTextAreaElement>,
        HTMLTextAreaElement
      >
    >,
    any,
    any
  >;

2 - I tried to pass a custom textarea component and it failed. The compilation works, the type-system works but if I type anything, the component loses focus. React-mde is basically not working.

@vitorqb I made a WIP PR containing your commits and the chages to the typesystem.. Meanwhile, I will have to revert your changes. The PR: #238

@andrerpena
Copy link
Owner

Released here: https://github.com/andrerpena/react-mde/releases/tag/9.1.0

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.

None yet

3 participants