-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make placeholder accessible #29
base: main
Are you sure you want to change the base?
Conversation
Clone of the PR facebook/lexical#6171 |
My review is in progress 📖 - I will have feedback for you in a few minutes! |
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
I have reviewed your code and found 2 potential issues.
<ContentEditable | ||
className="editor-input" | ||
placeholder={ | ||
<div className="editor-placeholder">{placeholder}</div> | ||
} | ||
aria-placeholder={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.
I noticed that we're passing aria-placeholder
as a prop to the ContentEditable component. While this is a step in the right direction for accessibility, we should verify if ContentEditable supports this attribute directly. If it doesn't, we might need to modify the ContentEditable component to ensure that the aria-placeholder
is correctly applied to the underlying HTML element. Could you please check the ContentEditable implementation and make sure this attribute is being correctly utilized?
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
placeholder={ | ||
<div className={placeholderClassName ?? 'ContentEditable__placeholder'}> | ||
{placeholder} | ||
</div> | ||
} |
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.
The placeholder
prop is currently required, but there's no validation to ensure it's not an empty string. Consider adding a check to prevent rendering an empty placeholder, which could improve the component's robustness and prevent potential rendering issues. You could modify the placeholder rendering logic like this:
placeholder={
placeholder ? (
<div className={placeholderClassName ?? 'ContentEditable__placeholder'}>
{placeholder}
</div>
) : null
}
This change ensures that the placeholder is only rendered when it has content.
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.
/review |
PR Reviewer Guide 🔍(Review updated until commit e94e1e9)
|
Persistent review updated to latest commit e94e1e9 |
@coderabbitai full review |
Persistent review updated to latest commit e94e1e9 |
Actions performedFull review triggered. |
PR Code Suggestions ✨
|
No comment from coderabbit |
User description
Placeholder won't read to screen readers, it technically can be read but it is not in the expected position in the flow. Instead, it should use
placeholder
aria-placeholder
on the contenteditable.Placeholder is now part of the ContentEditable (backward compatible for now), for two reasons:
contenteditable
with the placeholder. That's how nativeplaceholder
andinput
work.Before, doesn't read, interferes with the flow:
Screen.Recording.2024-05-24.at.3.15.28.PM.mov
After:
Screen.Recording.2024-05-24.at.3.28.28.PM.mov
Description by Korbit AI
Note
This feature is in early access. You can enable or disable it in the Korbit Console.
What change is being made?
Refactor placeholder handling to improve accessibility by integrating placeholder text directly into the
ContentEditable
component and removing the separatePlaceholder
component.Why are these changes being made?
This change ensures that placeholder text is more accessible by using the
aria-placeholder
attribute and simplifies the codebase by consolidating placeholder logic within theContentEditable
component. This approach also reduces redundancy and potential inconsistencies in placeholder handling across different components.PR Type
enhancement
Description
ContentEditable
component.Placeholder
component, simplifying the codebase and reducing redundancy.aria-placeholder
attributes to enhance accessibility.ContentEditableElement
to manage editable state and placeholder logic.Changes walkthrough 📝
10 files
App.tsx
Integrate placeholder text into ContentEditable component
examples/react-rich/src/App.tsx
Placeholder
component.ContentEditable
.aria-placeholder
attribute for accessibility.Editor.tsx
Refactor placeholder handling in Editor component
packages/lexical-playground/src/Editor.tsx
Placeholder
component.ContentEditable
.ImageComponent.tsx
Update ImageComponent to use integrated placeholder
packages/lexical-playground/src/nodes/ImageComponent.tsx
Placeholder
component.ContentEditable
.InlineImageComponent.tsx
InlineImageComponent refactored for integrated placeholder
packages/lexical-playground/src/nodes/InlineImageNode/InlineImageComponent.tsx
Placeholder
component.ContentEditable
.StickyComponent.tsx
StickyComponent updated for direct placeholder integration
packages/lexical-playground/src/nodes/StickyComponent.tsx
Placeholder
component.ContentEditable
.index.tsx
CommentPlugin refactored for direct placeholder use
packages/lexical-playground/src/plugins/CommentPlugin/index.tsx
Placeholder
component.ContentEditable
.ContentEditable.tsx
Enhance ContentEditable with integrated placeholder support
packages/lexical-playground/src/ui/ContentEditable.tsx
placeholder
andaria-placeholder
properties.ContentEditable
.LexicalContentEditable.tsx
Refactor LexicalContentEditable for placeholder integration
packages/lexical-react/src/LexicalContentEditable.tsx
ContentEditableElement
.LexicalContentEditableElement.tsx
Introduce ContentEditableElement for placeholder management
packages/lexical-react/src/shared/LexicalContentEditableElement.tsx
ContentEditableElement
.ContentEditable.css
Add styling for ContentEditable placeholder
packages/lexical-playground/src/ui/ContentEditable.css
ContentEditable__placeholder
.