Skip to content

RichText component: Add label and/or help text attributes #33465

Open

Description

@thatdevgirl

What problem does this address?

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:

  1. Placeholder text disappears when focus is on the input field.
  2. Placeholder text disappears when there is content in the input field.
  3. 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.
  4. Placeholder text is not necessarily read by all screen readers.

In case you want to read a ton of research about placeholders, the W3C has a page on placeholder research and accessibility

What is your proposed solution?

Please consider add a label and/or help text attribute to the RichText component, similar to what exists in the TextControl component.

Activity

  1. added
    [Feature] Rich Text
    on Jul 16, 2021
  2. talldan commented on Jul 16, 2021

    @talldan
    Contributor

    What's the best HTML markup for something like this, @thatdevgirl?

  3. thatdevgirl commented on Jul 16, 2021

    @thatdevgirl
    Author

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

  4. added
    [Type] Enhancement
    on Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Rich Text[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions