Page MenuHomePhabricator

HTMLForm: Add support for fieldset description and "optional" tag
Closed, ResolvedPublic3 Estimated Story Points

Description

The Codex Field component (when used as a fieldset) supports a description below the legend, and an "(optional)" tag as part of the legend, (see Codex docs). HTMLForm has the concept of section labels (which is what is put in the legend), but not section descriptions or optional tags.

  • Add options to HTMLForm for descriptions and optional tags for sections
  • Override getLegend() in CodexHTMLForm and implement support for them
  • (Maybe?) implement support for this in plain HTMLForm and OOUIHTMLForm

Event Timeline

Catrope renamed this task from HTMLForm: Add support fieldset description and "optional" tag to HTMLForm: Add support for fieldset description and "optional" tag.Mar 4 2024, 6:26 AM
Catrope created this task.

FWIW, while the Codex Field component differentiates the label text and description text for fieldsets, they are both contained within the <legend> element - in my research, I found that this was the only reliable way to ensure that, when you tab into a fieldset, both the label and description are read to you. I still think this task needs to be done to allow you to pass in separate things for label, optional flag, and description, I just wanted to make this note about the resulting markup.

lwatson set the point value for this task to 3.Mar 18 2024, 5:18 PM
AnneT changed the task status from Open to In Progress.Mar 18 2024, 8:23 PM
AnneT claimed this task.

@Catrope I want to clarify what this task covers. I see 3 distinct things that could have descriptions and optional flags:

  • HTMLForm sections, which are outputs as <fieldset>s
  • HTMLFormFields
  • HTMLFormFields that are fieldsets, e.g. a group of radios (is there even a concept of this, or are fieldsets only used as sections?)

Does this task only cover the first one? Do we need to cover the other two in a separate task?

@Catrope I want to clarify what this task covers. I see 3 distinct things that could have descriptions and optional flags:

  • HTMLForm sections, which are outputs as <fieldset>s
  • HTMLFormFields
  • HTMLFormFields that are fieldsets, e.g. a group of radios (is there even a concept of this, or are fieldsets only used as sections?)

There isn't, fieldsets are only used as sections. I'm open to suggestions for handling this differently, but I think the best way to fit our Field component in the mold of how HTMLForm wants to structure its forms is probably to use fieldsets for sections, and non-fieldset Fields for each HTMLFormField (both single input fields and compound fields).

Does this task only cover the first one? Do we need to cover the other two in a separate task?

That's a great question, I hadn't considered this. The new design for Special:Block only applies descriptions and optional tags to sections (fieldsets), but I think that's in part because Special:Block (ab)uses sections to create fieldsets, in such a way that most sections only contain one field (or a group of checkboxes). For now, I think it makes the most sense to just do descriptions for fieldsets (#1), and leave descriptions for individual fields (#2) for later, if we ever need it. (Most existing HTMLForm designs appear to work around the lack of descriptions by making more use of help texts instead.)

Change 1012441 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[mediawiki/core@master] CodexHTMLForm: Add support for fieldset and legend

https://gerrit.wikimedia.org/r/1012441

Change #1012441 merged by jenkins-bot:

[mediawiki/core@master] CodexHTMLForm: Add support for fieldset, description, and optional

https://gerrit.wikimedia.org/r/1012441