From b96f86fe59b112056ac02003c73a65e7327b20a9 Mon Sep 17 00:00:00 2001 From: nur-alam Date: Tue, 3 Feb 2026 10:29:38 +0600 Subject: [PATCH 1/3] fix(dashboard): Ensure form state is properly reset after successful mutation by passing formId in payload. --- .../js/frontend/dashboard/pages/settings.ts | 21 +++++++++++++++---- .../frontend/dashboard/settings/_profile.scss | 8 +++---- .../account/settings/preferences.php | 3 +-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/assets/src/js/frontend/dashboard/pages/settings.ts b/assets/src/js/frontend/dashboard/pages/settings.ts index d08863c31a..219863b3f9 100644 --- a/assets/src/js/frontend/dashboard/pages/settings.ts +++ b/assets/src/js/frontend/dashboard/pages/settings.ts @@ -63,6 +63,11 @@ interface PreferencesFormProps { auto_play_next: boolean; theme: string; font_scale: number; + formId?: string; +} + +interface UpdateNotificationProps { + [key: string]: boolean | string; } const settings = () => { @@ -100,7 +105,8 @@ const settings = () => { this.handleResetPassword = this.handleResetPassword.bind(this); this.handleUpdateNotification = this.query.useMutation(this.updateNotification, { - onSuccess: (data: TutorMutationResponse) => { + onSuccess: (data: TutorMutationResponse, payload: UpdateNotificationProps) => { + this.form.reset(payload?.formId as string, payload as unknown as Record); this.toast.success(data?.message ?? __('Notification settings updated', 'tutor')); }, onError: (error: Error) => { @@ -168,7 +174,8 @@ const settings = () => { }); this.savePreferencesMutation = this.query.useMutation(this.updatePreferences, { - onSuccess: (data: TutorMutationResponse) => { + onSuccess: (data: TutorMutationResponse, payload: PreferencesFormProps) => { + this.form.reset(payload?.formId || '', payload as unknown as Record); this.toast.success(data?.message ?? __('Preferences saved successfully', 'tutor')); }, onError: (error: Error) => { @@ -177,16 +184,22 @@ const settings = () => { }); }, - async updatePreferences(payload: Record) { + async updatePreferences(payload: PreferencesFormProps) { return wpAjaxInstance.post(endpoints.UPDATE_USER_PREFERENCES, payload) as unknown as Promise< TutorMutationResponse >; }, - async updateNotification(payload: Record) { + async updateNotification(payload: UpdateNotificationProps) { const transformedPayload = Object.keys(payload).reduce( (formattedPayload, key) => { const value = payload[key]; + + if (typeof value !== 'boolean') { + formattedPayload[`${key}`] = value; + return formattedPayload; + } + const stringValue = typeof value === 'boolean' ? (value ? 'on' : 'off') : value; if (!key.includes('__')) { diff --git a/assets/src/scss/frontend/dashboard/settings/_profile.scss b/assets/src/scss/frontend/dashboard/settings/_profile.scss index 7107a7b8d0..4ee1c89b7f 100644 --- a/assets/src/scss/frontend/dashboard/settings/_profile.scss +++ b/assets/src/scss/frontend/dashboard/settings/_profile.scss @@ -108,7 +108,9 @@ body:has(#wpadminbar) { } .tutor-profile-notification-content { - border-top: 1px solid $tutor-border-idle; + &.tutor-profile-notification-content-first { + border-top: 1px solid $tutor-border-idle; + } } .tutor-profile-notification-toggle { @@ -142,8 +144,4 @@ body:has(#wpadminbar) { .tutor-input-field { margin-bottom: 0px; } - - .tutor-profile-notification-content { - border-top: 1px solid $tutor-border-idle; - } } diff --git a/templates/dashboard/account/settings/preferences.php b/templates/dashboard/account/settings/preferences.php index aa3cb4dee0..fdc0c3f510 100644 --- a/templates/dashboard/account/settings/preferences.php +++ b/templates/dashboard/account/settings/preferences.php @@ -41,9 +41,8 @@ shouldFocusError: true, defaultValues: })' - x-bind="getFormBindings()" - @submit="handleSubmit((data) => { savePreferencesMutation?.mutate(data); })($event)" + @submit="handleSubmit((data) => { savePreferencesMutation?.mutate({...data, formId: ''}); })($event)" >
From 7046a033eaf1eec95c76260e1d8ebd8760ab9c52 Mon Sep 17 00:00:00 2001 From: nur-alam Date: Tue, 3 Feb 2026 11:54:43 +0600 Subject: [PATCH 2/3] style: remove unused CSS for profile notification content border --- assets/src/scss/frontend/dashboard/settings/_profile.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/assets/src/scss/frontend/dashboard/settings/_profile.scss b/assets/src/scss/frontend/dashboard/settings/_profile.scss index 4ee1c89b7f..34bcd2f303 100644 --- a/assets/src/scss/frontend/dashboard/settings/_profile.scss +++ b/assets/src/scss/frontend/dashboard/settings/_profile.scss @@ -107,12 +107,6 @@ body:has(#wpadminbar) { } } - .tutor-profile-notification-content { - &.tutor-profile-notification-content-first { - border-top: 1px solid $tutor-border-idle; - } - } - .tutor-profile-notification-toggle { display: flex; align-items: center; From 4d0ef6fb50580de26ddd327107e5da1097b01690 Mon Sep 17 00:00:00 2001 From: nur-alam Date: Thu, 5 Feb 2026 13:20:47 +0600 Subject: [PATCH 3/3] refactor(dashboard): Use site-wide autoload setting as default for auto_play_next preference when user preference is not set, consolidate user preferences sections into single card --- .../dashboard/account/settings/preferences.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/templates/dashboard/account/settings/preferences.php b/templates/dashboard/account/settings/preferences.php index fdc0c3f510..c620ff4834 100644 --- a/templates/dashboard/account/settings/preferences.php +++ b/templates/dashboard/account/settings/preferences.php @@ -16,7 +16,6 @@ use Tutor\Components\Constants\InputType; use Tutor\Components\Constants\Size; -// Theme options. $theme_options = UserPreference::get_theme_options(); $font_scale_options = UserPreference::get_font_scale_options(); @@ -24,8 +23,10 @@ // Load current user preferences to seed the form. $user_preferences = ( new UserPreference( false ) )->get_preferences(); +$autoload_course_content = (bool) tutor_utils()->get_option( 'autoload_next_course_content' ); + $default_values = array( - 'auto_play_next' => isset( $user_preferences['auto_play_next'] ) ? (bool) $user_preferences['auto_play_next'] : false, + 'auto_play_next' => isset( $user_preferences['auto_play_next'] ) ? (bool) $user_preferences['auto_play_next'] : $autoload_course_content, 'theme' => isset( $user_preferences['theme'] ) ? $user_preferences['theme'] : UserPreference::DEFAULT_THEME, 'font_scale' => isset( $user_preferences['font_scale'] ) ? (int) $user_preferences['font_scale'] : UserPreference::DEFAULT_FONT_SCALE, ); @@ -46,7 +47,7 @@ >
- +
@@ -67,11 +68,6 @@ ?>
- - - -
-
@@ -94,10 +90,6 @@ ?>
-
- -
-