-
Notifications
You must be signed in to change notification settings - Fork 839
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
[EuiMarkdownEditor] Added placeholder
prop
#5151
[EuiMarkdownEditor] Added placeholder
prop
#5151
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Checked in the 3 browsers too. Just one question around TS.
@@ -52,7 +55,7 @@ import { EuiResizeObserver } from '../observer/resize_observer'; | |||
|
|||
type CommonMarkdownEditorProps = Omit< | |||
HTMLAttributes<HTMLDivElement>, | |||
'onChange' | |||
'onChange' | 'placeholder' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the omition of placeholder
is necessary here? I wouldn't think that this is an inherit attribute of a div
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 @thompsongl any thoughts here? placeholder
is certainly not an HTML property that exists on a <div>
element nor on the extended HTMLElement. Why would it be ignored from the props table if not omitted from HTMLAttributes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr: This is the correct way to handle cases like this.
The HTMLElement
you linked to is not the same thing as the HTMLAttributes
interface from React in the screenshot. By default, any HTML element in React can accept placeholder
. You can see this if you add a placeholder
to EuiMarkdownEditor
on master right now; TypeScript is fine with it even though it isn't passed through to the correct element (textarea
).
The reason it doesn't show up in the props table unless Omit
ed from HTMLAttributes
is because we purposefully don't add default HTMLAttributes
extensions to the table. If we did each table would have ~250 rows. So using Omit
and redefining the placeholder
type is the best method we currently have to bypass the automatic omission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL... But I think React is wrong 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think React is wrong
I agree 🙈
Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/ |
Summary
Closes #5128.
This PR adds a
placeholder
prop toEuiMarkdownEditor
.Checklist
[ ] Checked in mobile[ ] Checked Code Sandbox works for the any docs examples[ ] Checked for breaking changes and labeled appropriately[ ] Checked for accessibility including keyboard-only and screenreader modes