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

[EuiMarkdownEditor] Added placeholder prop #5151

Merged
merged 7 commits into from
Sep 9, 2021

Conversation

elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Sep 7, 2021

Summary

Closes #5128.

This PR adds a placeholder prop to EuiMarkdownEditor.

placeholder@2x

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • [ ] Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • [ ] Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • [ ] Checked for breaking changes and labeled appropriately
  • [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/

@elizabetdev elizabetdev marked this pull request as ready for review September 8, 2021 11:30
@elizabetdev elizabetdev requested a review from cchaos September 8, 2021 11:37
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/

Copy link
Contributor

@cchaos cchaos left a 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'
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was not omitting the placeholder the prop and description were not displaying in the props table. Once I omitted I could finally see it:

Screenshot 2021-09-08 at 15 38 32

So I'm assuming HTMLAttributes<HTMLDivElement> includes all these "Standard HTML Attributes":

Screenshot 2021-09-08 at 15 56 42

Copy link
Contributor

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?

Copy link
Contributor

@thompsongl thompsongl Sep 8, 2021

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 Omited 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.

Copy link
Contributor

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 😝

Copy link
Contributor

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 🙈

@thompsongl thompsongl removed the request for review from chandlerprall September 8, 2021 21:13
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5151/

@elizabetdev elizabetdev merged commit 6f7d4ad into elastic:master Sep 9, 2021
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.

[EuiMarkdownEditor] Enhancement request: Placeholder text
4 participants