Fix unstable useSelect() return value in useCustomerEffortScoreModal#63554
Fix unstable useSelect() return value in useCustomerEffortScoreModal#63554jorgeatorres merged 6 commits intotrunkfrom
useSelect() return value in useCustomerEffortScoreModal#63554Conversation
c6a1637 to
6e2414b
Compare
useSelect in useCustomerEffortScoreModaluseSelect() return value in useCustomerEffortScoreModal
Testing GuidelinesHi @Konamiman @opr , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughStabilizes the hook's selection data by returning a normalized shown-for-actions list and exposing a wasPreviouslyShown(action) helper; adjusts editor controls' spacing props for the CES feedback button; and adds patch changelog entries in the CES package and WooCommerce plugin. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.ts`:
- Around line 24-25: The code directly casts
getOption(SHOWN_FOR_ACTIONS_OPTION_NAME) to string[] and calls includes on it,
which can throw if the option is not an array; update the use of shownForActions
so you first retrieve the raw value via
getOption(SHOWN_FOR_ACTIONS_OPTION_NAME), validate/normalize it to an array
(falling back to EMPTY_SHOWN_ACTIONS) before storing into the shownForActions
variable, and then use shownForActions.includes(...) safely; also apply the same
normalization/guard where shownForActions is stored/used elsewhere (referenced
symbols: getOption, SHOWN_FOR_ACTIONS_OPTION_NAME, EMPTY_SHOWN_ACTIONS,
shownForActions, and the includes call).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 82d4a583-3621-43a7-9f11-f4a6c996277f
📒 Files selected for processing (4)
packages/js/customer-effort-score/changelog/fix-62340-cespackages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.tsplugins/woocommerce/changelog/fix-62340-cesplugins/woocommerce/client/blocks/assets/js/editor-components/ces-feedback-button/index.tsx
|
Size Change: +56 B (0%) Total Size: 5.98 MB |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
opr
left a comment
There was a problem hiding this comment.
Thanks, looks good, I would recommend fixing the code that coderabbit flagged, I don't think it breaks anything if it errors, but good to fix while we're here.
c84e333 to
eeed9d7
Compare
Changes proposed in this Pull Request:
The
useCustomerEffortScoreModalhook was triggering auseSelectwarning in the console because the inlinewasPreviouslyShownfunction as well as the hardcoded fallback value of[] resulted in a new reference on every call.I noticed the warning while testing #63541 as the product collection block renders a feedback button in the settings.
This PR makes the
useSelect()return a consistent value and keeps the public API the same. It also addresses a few deprecation notices being triggered by the modal itself.Related to #62340.
How to test the changes in this Pull Request:
useSelectwarning mentioningwasPreviouslyShown.Testing that has already taken place:
Milestone