Skip to content

Fix: "Enable Mobile Responsive" toggle resets to on after notification update#124

Open
AmitPaul-akp wants to merge 1 commit into
WPDevelopers:masterfrom
AmitPaul-akp:amit-dev
Open

Fix: "Enable Mobile Responsive" toggle resets to on after notification update#124
AmitPaul-akp wants to merge 1 commit into
WPDevelopers:masterfrom
AmitPaul-akp:amit-dev

Conversation

@AmitPaul-akp
Copy link
Copy Markdown

Summary

  • "Enable Mobile Responsive" toggle in the NotificationX builder snaps back to on every time an existing notification is updated, even if the user had previously turned it off — so the saved preference is silently discarded on each save.
  • Root cause is nxdev/notificationx/components/WrapperWithLoader.tsx: its useEffect keyed on builderContext.values.type calls setFieldValue("is_mobile_responsive", nx_type !== "custom") on every type change — including the initial hydration when an existing notification's saved type populates the form, which overwrites the saved toggle before the user even touches the form.
  • This PR adds an nx_id guard so the override only runs when there is no existing record (i.e. a new notification being created). Existing entries keep whatever the user previously saved.

Reproduction (before fix)

  1. Create any NotificationX notification (e.g. WooCommerce Sales) and leave the "Enable Mobile Responsive" toggle off under Customize → Themes → Mobile.
  2. Save the notification.
  3. Reopen the same notification from the list and click Update without changing anything else.
  4. Reopen it once more — the toggle is back to on, mobile responsive is silently re-enabled.

Verified locally on NotificationX 3.2.7. Video reproduction: https://d.pr/v/YkVmYO

Fix

nxdev/notificationx/components/WrapperWithLoader.tsx only. +3 / -1. The setFieldValue("is_mobile_responsive", …) call inside the type-change effect is wrapped in an nx_id guard so it short-circuits on edit and only runs when creating a new notification.

- builderContext.setFieldValue( "is_mobile_responsive", nx_type !== "custom");
+ if ( ! builderValues?.nx_id ) {
+     builderContext.setFieldValue( "is_mobile_responsive", nx_type !== "custom" );
+ }

Test plan

  • Create a new notification of any non-custom type → "Enable Mobile Responsive" defaults to on (unchanged behavior).
  • Create a new notification of type custom → toggle defaults to off (unchanged behavior).
  • Open an existing notification with the toggle set to off, save without changes, reopen → toggle is still off. ✅ (was failing before)
  • Open an existing notification with the toggle set to on, save, reopen → toggle is still on.
  • Change the type of an existing notification → toggle retains the user's saved value rather than snapping back to the type-based default.
  • Other tabs/fields on the builder are unaffected; themes_tab still switches correctly when the type changes.

Build artifacts

This PR touches only the webpack source. The compiled assets/admin/js/admin.js is intentionally not committed — it should be regenerated by the standard build pipeline before release.

Reported by

Client-reported bug via Fluent Boards — #81297 Bug Fix: NotificationX mobile responsive setting automatically re-enables after notification update.

…e (#81297)

The useEffect in WrapperWithLoader fires whenever builderContext.values.type
changes, including the moment an existing notification's saved values populate
the form on edit. It was unconditionally calling
setFieldValue("is_mobile_responsive", nx_type !== "custom"), which silently
overwrote the user's saved toggle (e.g. false) back to true before save, so
updating any existing notification re-enabled mobile responsive every time.

Guard the override behind !builderValues?.nx_id so it only applies when
creating a new notification. For existing entries the user's saved value is
preserved.

Fluent Boards task: https://projects.startise.com/wp-admin/admin.php?page=fluent-boards#/boards/19/tasks/81297-bug-fix-notificationx-mobile-responsive-setting-automatically-re-enables-after-notification-update

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant