You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RichText component: Add label and/or help text attributes #33465
[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditable[Type] EnhancementA suggestion for improvement.
It would be useful for the RichText component to have a label or help text attribute (or both!) to allow block developers to add text to the component to describe its intent within the block.
For example, if I were to create a block that would contain a person's profile information, that block would have attributes for the person's name and their bio. The bio would use the RichText component. It would be helpful to a content editor to see a label connected to that bio component, saying "Biography" or "Write a short bio about this person".
Right now, the only way to include any such description is with the placeholder text. This is not ideal for a couple of reasons:
Placeholder text disappears when focus is on the input field.
Placeholder text disappears when there is content in the input field.
The first field of a block automatically gains focus when the block is added to the editor. If that field is a RichText component that has placeholder text, the content editor will not see the placeholder text unless they click out of that field. They may never see the placeholder text if they add that block and just start typing.
Placeholder text is not necessarily read by all screen readers.
@talldan Ideally, I would change it to something like this:
<label for="richtext-control-0">Label for my rich text field</label>
<div role="textbox" aria-multiline="true" id="richtext-control-0" aria-describedby="richtext-control-0__help"></div>
<p id="richtext-control-0__help">Here is some help text for this field</p>
This markup is inspired / largely copied from the markup used by the TextControl component. The <div role=textbox> is from the current Rich Text control.
The textbox has an ID that is used in the for attribute in the <label> tag above it.
The <p> tag below it contains the help text. Its ID is used in the aria-describedby attribute on the textbox div.
[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditable[Type] EnhancementA suggestion for improvement.
Activity
talldan commentedon Jul 16, 2021
What's the best HTML markup for something like this, @thatdevgirl?
thatdevgirl commentedon Jul 16, 2021
@talldan Ideally, I would change it to something like this:
This markup is inspired / largely copied from the markup used by the
TextControlcomponent. The<div role=textbox>is from the current Rich Text control.The textbox has an ID that is used in the
forattribute in the<label>tag above it.The
<p>tag below it contains the help text. Its ID is used in thearia-describedbyattribute on the textbox div.