Open Bug 2024754 Opened 8 months ago Updated 7 months ago

Remove React 16 addEventListener/setAttribute workarounds for moz-radio-group and moz-button in ReportContent

Categories

(Firefox :: New Tab Page, defect, P3)

defect

Tracking

()

People

(Reporter: maxx, Unassigned)

References

(Blocks 1 open bug)

Details

Summary:

ReportContent uses useRef + useEffect + addEventListener("change", ...) on moz-radio-group to detect radio selection, and calls submitButton.setAttribute("disabled","") / removeAttribute("disabled") imperatively to control the submit button's state. Both patterns were required in React 16, which could not handle custom element events via props or set boolean properties correctly.

React 19 supports onChange on custom elements and correctly sets disabled as a property on custom elements.

Steps to fix:

  • content-src/components/DiscoveryStreamComponents/ReportContent/ReportContent.jsx:
    • remove radioGroupRef and submitButtonRef
    • pass onChange={handleRadioChange} directly on <moz-radio-group>
    • replace the imperative disabled logic with disabled={!valueSelected} on the <moz-button> submit element.
      • The useEffect block (lines ~136–168) and updateSubmitState helper become unnecessary and can be deleted.

I am having deja vu.

I don't think we can do this until React 19 is on release.

Severity: -- → S2
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.