Closed Bug 1882835 Opened 7 months ago Closed 7 months ago

Allow No Initial Selection in XUL MenuList

Categories

(Toolkit :: UI Widgets, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: nordzilla, Assigned: nordzilla)

References

Details

Attachments

(1 file)

Problem Description

The XUL MozMenuList implementation has a setInitialSelection() implementation.

It gets called here in menulist.js.

I have a use case for the Select Translations Panel in which I want to leave the menulist with no item selected, such as requesting a translation from a language that we do not yet support. There is no valid value that the menulist should have in this case.


Proposal

I would like to add a way to allow menulists to remain unselected when initialized. This should be a non-breaking change, and an opt-in experience.

My initial approach is to check for an attribute noinitialselection="true" (similar to noautofocus) in which case the menulist will not default to selecting one of the values when initialized.

But I'm certainly open to feedback on other approaches to solve this problem.

Example

<panel>
  <menulist value="" label="None" noinitialselection="true">
    <menupopup>
      <menuitem value="1" label="One"/>
      <menuitem value="2" label="Two"/>
      <menuitem value="3" label="Three"/>
    </menupopup>
  </menulist>
</panel>
setInitialSelection() {
  if (this.getAttribute("noinitialselection") === "true") {
    return;
  }
  // Snip...
}

Allows XUL MenuList to have no selected value if
the noinitialselection attribute is specified.

Summary: Convert menulist to custom element → Allow No Initial Selection in XUL MenuList
Attachment #9388455 - Attachment description: WIP: Bug 1882835 - Allow no initial selection in XUL MenuList → Bug 1882835 - Allow no initial selection in XUL MenuList
Priority: -- → P3
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c5ddc3b211e5 Allow no initial selection in XUL MenuList r=hjones
Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
Blocks: 1886276
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: