fix(setup-wizard): sync image picker selection to Vue v-model#1193
Conversation
The setup wizard "Your Company" step and other image setting fields
use a hidden <input> with a Vue v-model binding to hold the selected
media library attachment ID. When wu_initialize_imagepicker set that
value with jQuery's .val() (and later .trigger('input')), Vue 2's
native input listener never fired because jQuery's trigger() does not
dispatch native DOM events.
The consequence: on the wizard's company_logo field (and the matching
settings-page field), Vue's reactive data stayed empty after the user
picked an image, so the next re-render reset the hidden input back to
'' and the uploaded image ID was silently lost when the form was
submitted.
Fix wu_initialize_imagepicker (and the matching .wu-remove-image
handler) to dispatch native 'input' and 'change' events on the hidden
input after updating its value, so Vue's v-model listener picks up
the change. Verified end-to-end on both the setup wizard and the
settings page that the uploaded logo now persists in
wp-ultimo_v2_settings and renders on reload.
Ref #116
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughImage picker now dispatches native ChangesImage picker native event dispatching
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
SummaryFix the Ultimate Multisite setup wizard "Your Company" step (and matching The bugThe image setting fields ( The fixIn const $hidden = that.find('input').val(mediaObject.id);
$hidden.each(function() {
this.dispatchEvent(new Event('input', { bubbles: true }));
this.dispatchEvent(new Event('change', { bubbles: true }));
});VerificationEnd-to-end via headless browser against the local dev install:
Notes
Merged via PR #1193 to main. aidevops.sh v3.15.38 spent 29s on this as a headless bash routine. |
|
Performance Test Results Performance test results for 8b342d0 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Fix the Ultimate Multisite setup wizard "Your Company" step (and matching
settings-page field) so the uploaded Company Logo persists when the user
picks an attachment in the Media Library modal.
The bug
The image setting fields (
company_logo, etc.) render a hidden<input>with a Vue
v-modelbinding so the picked attachment ID round-trips throughVue's reactive data on the way to form submission. The picker's
wu_initialize_imagepickerJS handler set that input via jQuery's.val()and then called
.trigger('input').trigger('change'). jQuery's.trigger()does not dispatch native DOM events, and Vue 2's v-model registers a
native
addEventListener('input', ...)— so Vue never saw the change.The consequence: Vue's reactive
company_logostayed empty after the userpicked an image. As soon as any other reactive field changed, Vue re-rendered
and reset the hidden input back to
""— silently dropping the uploadedimage ID before the form was submitted.
The fix
In
assets/js/functions.js(wu_initialize_imagepicker), dispatch nativeinputandchangeevents on the hidden input after updating its value,in both the media-frame
selecthandler and the.wu-remove-imageclickhandler. The minified bundle is rebuilt to match.
Verification
End-to-end via headless browser against the local dev install:
wu_general.company_logo === "14"(was"")wp-ultimo_v2_settings['company_logo'] === '14'step=your-company) → pick image → Continuestep=defaults, logo persistedNotes
assets/js/functions.min.jsis regenerated because.min.jsfiles aretracked in this repo (despite the general
AGENTS.mdguideline), so thefix must ship the rebuilt minified bundle to take effect at runtime.
Ref #116
Summary by CodeRabbit
Release Notes