-
Notifications
You must be signed in to change notification settings - Fork 217
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
add placeholder to the div, update example with additional prop #64
base: master
Are you sure you want to change the base?
Conversation
Please merge... |
please merge this :) |
Well, it could be done easily with some CSS - Without this merge. Just add "placeholder" attribute like this: <ContentEditable
...
placeholder={"Hello, World!"}
/> And add this to your CSS: [contenteditable=true]:empty:before {
content: attr(placeholder);
display: block;
color: #aaa;
} |
I agree that it is easy to do it sounds like a basic feature to have in such component.I would vote in favor to have placeholder built in. Cheers! |
I do not really like the way the placeholder is implemented in this PR. If the placeholder is Hello World, and someone explicitly types Hello World, then blurs the component, then focuses it again, the text they typed will disappear. The solution with CSS is shorter, simpler, and does not have this problem. |
please merge this! placeholder is very important |
@enkhchuluun Didn't you read the above ? |
For Typescript users: To get past the Typescipt compiler using the solution of @atagulalan , I had to write my own type definition file. file: contentEditable.d.ts
@lovasoa Let me know if you want stricter types, I'd be happy to update them. |
@RobertB4 Thank you for your work. Yes, I would definitely merge a PR implementing stricter types ! |
WOW NICE! |
@atagulalan hii, thank you for your solution! However, I've encountered a problem that if I need to generate tag or other tags under the contenteditable component( press enter generates p instead of div), the tag should be inside the component in the first place, then it conflicts with the pseudo-element :empty in css. I am wondering if there's any solution to this. Thank you. |
Pls merge this PR. Am in need of this Placeholder |
please merge this! placeholder is very important |
@syed3kt @rajasurya7 just use this solution #64 (comment) |
The suggested solution makes the caret to disappear when the input is empty and focused. |
For anyone having trouble with typings or do not want to update them you can just use the aria-placeholder and change the |
No description provided.