-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,26 @@ import './ContentEditable.css'; | |
import {ContentEditable} from '@lexical/react/LexicalContentEditable'; | ||
import * as React from 'react'; | ||
|
||
type Props = { | ||
className?: string; | ||
placeholderClassName?: string; | ||
placeholder: string; | ||
}; | ||
|
||
export default function LexicalContentEditable({ | ||
className, | ||
}: { | ||
className?: string; | ||
}): JSX.Element { | ||
return <ContentEditable className={className || 'ContentEditable__root'} />; | ||
placeholder, | ||
placeholderClassName, | ||
}: Props): JSX.Element { | ||
return ( | ||
<ContentEditable | ||
className={className ?? 'ContentEditable__root'} | ||
aria-placeholder={placeholder} | ||
placeholder={ | ||
<div className={placeholderClassName ?? 'ContentEditable__placeholder'}> | ||
{placeholder} | ||
</div> | ||
} | ||
Comment on lines
+29
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The placeholder={
placeholder ? (
<div className={placeholderClassName ?? 'ContentEditable__placeholder'}>
{placeholder}
</div>
) : null
} This change ensures that the placeholder is only rendered when it has content.
|
||
/> | ||
); | ||
} |
This file was deleted.
This file was deleted.
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 thearia-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?