tektoncd / dashboard

A dashboard for Tekton!
Apache License 2.0
877 stars 265 forks source link

Adopt ComboBox selectedItem prop #3749

Closed AlanGreene closed 2 weeks ago

AlanGreene commented 2 weeks ago

Changes

Follow-up to https://github.com/tektoncd/dashboard/pull/3667 now that we've updated to @carbon/react@1.70

Remove previous workaround and adopt the selectedItem prop to make the ComboBox component fully controlled.

To avoid the previous issue where the ComboBox would get into a loop or cause the tests to crash due to OOM, we memoise the value passed to selectedItem to ensure the same reference is kept if the value is unchanged, e.g. in case of a selected namespace: { id: namespace, text: namespace } we memoise on the id field so the same object is returned unless the namespace changes. This avoid the ComboBox unnecessarily re-rendering, and also handles the case of translated text for the 'All namespaces' option.

/kind misc

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

Release Notes

NONE
tekton-robot commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: briangleeson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/tektoncd/dashboard/blob/main/OWNERS)~~ [briangleeson] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment