From 938720602082dc50a1746bd2e33faa3d3a6096d4 Mon Sep 17 00:00:00 2001 From: Subodh Rajpopat <58080782+subodhr258@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:51:04 +0530 Subject: [PATCH] CustomSelectControl: Update Value from Fresh State (#67733) * CustomSelectControl: Prioritized props value over store * CustomSelectControl: Refactored Codebase to fix failing testcases * docs: Add changelog entry for CustomSelectControl font size reset fix * CustomSelectControl: Fetch the fresh state on each call instead of stale state * Tweak changelog text --------- Co-authored-by: subodhr258 Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: sarthaknagoshe2002 Co-authored-by: Rishit30G Co-authored-by: inc2734 --- packages/components/CHANGELOG.md | 1 + packages/components/src/custom-select-control/index.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 6a7b2545c2e68c..2dc35bd54b3eeb 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -45,6 +45,7 @@ ### Bug Fixes - `ResizableBox`: Make drag handles focusable ([#67305](https://github.com/WordPress/gutenberg/pull/67305)). +- `CustomSelectControl`: Update correctly when `showSelectedHint` is enabled ([#67733](https://github.com/WordPress/gutenberg/pull/67733)). ## 28.13.0 (2024-11-27) diff --git a/packages/components/src/custom-select-control/index.tsx b/packages/components/src/custom-select-control/index.tsx index 74da8a5c741060..339944f4198722 100644 --- a/packages/components/src/custom-select-control/index.tsx +++ b/packages/components/src/custom-select-control/index.tsx @@ -154,11 +154,11 @@ function CustomSelectControl< T extends CustomSelectOption >( const renderSelectedValueHint = () => { const selectedOptionHint = options ?.map( applyOptionDeprecations ) - ?.find( ( { name } ) => currentValue === name )?.hint; + ?.find( ( { name } ) => store.getState().value === name )?.hint; return ( - { currentValue } + { store.getState().value } { selectedOptionHint && (