Skip to content

Fix unstable useSelect() return value in useCustomerEffortScoreModal#63554

Merged
jorgeatorres merged 6 commits intotrunkfrom
fix/62340-ces
Mar 6, 2026
Merged

Fix unstable useSelect() return value in useCustomerEffortScoreModal#63554
jorgeatorres merged 6 commits intotrunkfrom
fix/62340-ces

Conversation

@jorgeatorres
Copy link
Copy Markdown
Member

@jorgeatorres jorgeatorres commented Mar 5, 2026

Changes proposed in this Pull Request:

The useCustomerEffortScoreModal hook was triggering a useSelect warning in the console because the inline wasPreviouslyShown function 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:

  1. Ensure WooCommerce usage tracking is enabled in WC > Settings > Advanced > WooCommerce.com.
  2. Open the Cart page on the admin for editing.
  3. Select the Cross-Sells block.
  4. Confirm there's no useSelect warning mentioning wasPreviouslyShown.
  5. Click the Help us improve button in the inspector and confirm the modal opens correctly.
    Screenshot 2026-03-05 at 14 54 35

Testing that has already taken place:

Milestone

Note: Check the box above to have the milestone automatically assigned when merged.
Alternatively (e.g. for point releases), manually assign the appropriate milestone.

@github-actions github-actions Bot added the package: @woocommerce/customer-effort-score issues related to @woocommerce/customer-effort-score label Mar 5, 2026
@jorgeatorres jorgeatorres changed the title Fix unstable useSelect in useCustomerEffortScoreModal Fix unstable useSelect() return value in useCustomerEffortScoreModal Mar 5, 2026
@jorgeatorres jorgeatorres marked this pull request as ready for review March 5, 2026 15:19
@jorgeatorres jorgeatorres requested a review from opr March 5, 2026 15:20
@woocommercebot woocommercebot requested review from a team and Konamiman and removed request for a team March 5, 2026 15:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

Testing Guidelines

Hi @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:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@github-actions github-actions Bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Mar 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 80b7f768-90ba-4e31-ae2d-df388f233406

📥 Commits

Reviewing files that changed from the base of the PR and between c84e333 and eeed9d7.

📒 Files selected for processing (1)
  • packages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.ts

📝 Walkthrough

Walkthrough

Stabilizes 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

Cohort / File(s) Summary
Changelog Entries
packages/js/customer-effort-score/changelog/fix-62340-ces, plugins/woocommerce/changelog/fix-62340-ces
Added patch changelog entries describing the fix that stabilizes the hook return value and resolves deprecation warnings in the feedback button editor.
CES Modal Hook
packages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.ts
Introduced internal EMPTY_SHOWN_ACTIONS fallback; useSelect now surfaces shownForActions and isLoading. Added wasPreviouslyShown(action: string) helper that checks membership in shownForActions. markCesAsShown normalizes the stored option before updating. Hook return now exposes wasPreviouslyShown (keeps isLoading, showCesModal, showProductMVPFeedbackModal).
Feedback Button Component
plugins/woocommerce/client/blocks/assets/js/editor-components/ces-feedback-button/index.tsx
Added UI refinement props (\_\_nextHasNoMarginBottom, \_\_next40pxDefaultSize) to TextareaControl and TextControl usages to adjust spacing and address deprecation warnings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing an unstable useSelect() return value in useCustomerEffortScoreModal hook.
Description check ✅ Passed The description is directly related to the changeset, explaining the root cause of the useSelect warning and how it was fixed while maintaining the public API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/62340-ces

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61bbf12 and 676d2b9.

📒 Files selected for processing (4)
  • packages/js/customer-effort-score/changelog/fix-62340-ces
  • packages/js/customer-effort-score/src/hooks/use-customer-effort-score-modal/index.ts
  • plugins/woocommerce/changelog/fix-62340-ces
  • plugins/woocommerce/client/blocks/assets/js/editor-components/ces-feedback-button/index.tsx

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

Size Change: +56 B (0%)

Total Size: 5.98 MB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

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.

@jorgeatorres jorgeatorres removed the request for review from Konamiman March 5, 2026 15:45
Copy link
Copy Markdown
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jorgeatorres jorgeatorres merged commit ab43129 into trunk Mar 6, 2026
46 checks passed
@jorgeatorres jorgeatorres deleted the fix/62340-ces branch March 6, 2026 22:18
@github-actions github-actions Bot added this to the 10.7.0 milestone Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: @woocommerce/customer-effort-score issues related to @woocommerce/customer-effort-score plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants