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:
[ ] Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
[ ] Release notes block below has been updated with any user facing changes (new features, significant UI changes, API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
[ ] Release notes contains the string "action required" if the change requires additional action from users switching to the new release
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
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 theComboBox
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 theid
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:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes