Skip to content

fix(setup-wizard): sync image picker selection to Vue v-model#1193

Merged
superdav42 merged 1 commit into
mainfrom
feature/auto-20260512-143304
May 12, 2026
Merged

fix(setup-wizard): sync image picker selection to Vue v-model#1193
superdav42 merged 1 commit into
mainfrom
feature/auto-20260512-143304

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented May 12, 2026

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-model binding so the picked attachment ID round-trips through
Vue's reactive data on the way to form submission. The picker's
wu_initialize_imagepicker JS 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_logo stayed empty after the user
picked an image. As soon as any other reactive field changed, Vue re-rendered
and reset the hidden input back to "" — silently dropping the uploaded
image ID before the form was submitted.

The fix

In assets/js/functions.js (wu_initialize_imagepicker), dispatch native
input and change events on the hidden input after updating its value,
in both the media-frame select handler and the .wu-remove-image click
handler. The minified bundle is rebuilt to match.

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 }));
});

Verification

End-to-end via headless browser against the local dev install:

Path Result
Settings page → pick image → re-render wu_general.company_logo === "14" (was "")
Settings page → Save Changes DB: wp-ultimo_v2_settings['company_logo'] === '14'
Settings page → reload Image renders, action buttons shown, upload hidden
Settings page → Remove image input cleared, Vue data cleared, upload button reshown
Setup wizard (step=your-company) → pick image → Continue Advances to step=defaults, logo persisted

Notes

  • No PHP changes — pure JS DOM-event compatibility fix.
  • Pre-existing ESLint baseline preserved (no new violations introduced).
  • assets/js/functions.min.js is regenerated because .min.js files are
    tracked in this repo (despite the general AGENTS.md guideline), so the
    fix must ship the rebuilt minified bundle to take effect at runtime.

Ref #116


Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved image picker to properly notify the application when images are selected or removed, ensuring all dependent interface components update correctly.

Review Change Stack

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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da50225b-8478-4694-a23d-1ef3b70adb92

📥 Commits

Reviewing files that changed from the base of the PR and between 82142b3 and e911dfc.

⛔ Files ignored due to path filters (1)
  • assets/js/functions.min.js is excluded by !**/*.min.js
📒 Files selected for processing (1)
  • assets/js/functions.js

📝 Walkthrough

Walkthrough

Image picker now dispatches native input and change events when images are selected or removed. The selection flow sets the hidden input to the image ID; the removal flow clears it. Both trigger native events for framework compatibility beyond jQuery listeners.

Changes

Image picker native event dispatching

Layer / File(s) Summary
Event dispatching on image selection and removal
assets/js/functions.js
Image selection sets the hidden input value to the selected image ID and dispatches native input/change events; image removal clears the input value and dispatches the same events to ensure dependent reactive state updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A picker once silent, now speaks with a voice,
Native events flow when you make your choice,
Remove an image, dispatch with care,
Frameworks now listen, they're all aware!
Events native, not jQuery's way,
Reactivity blooms on this fine day! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing image picker selection to sync with Vue v-model by dispatching native events instead of jQuery triggers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260512-143304

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.

@superdav42 superdav42 merged commit ddd628c into main May 12, 2026
10 of 11 checks passed
@superdav42
Copy link
Copy Markdown
Collaborator Author

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-model binding so the picked attachment ID round-trips through
Vue's reactive data on the way to form submission. The picker's
wu_initialize_imagepicker JS 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_logo stayed empty after the user
picked an image. As soon as any other reactive field changed, Vue re-rendered
and reset the hidden input back to "" — silently dropping the uploaded
image ID before the form was submitted.

The fix

In assets/js/functions.js (wu_initialize_imagepicker), dispatch native
input and change events on the hidden input after updating its value,
in both the media-frame select handler and the .wu-remove-image click
handler. The minified bundle is rebuilt to match.

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 }));
});

Verification

End-to-end via headless browser against the local dev install:

Path Result
Settings page → pick image → re-render wu_general.company_logo === "14" (was "")
Settings page → Save Changes DB: wp-ultimo_v2_settings['company_logo'] === '14'
Settings page → reload Image renders, action buttons shown, upload hidden
Settings page → Remove image input cleared, Vue data cleared, upload button reshown
Setup wizard (step=your-company) → pick image → Continue Advances to step=defaults, logo persisted

Notes

  • No PHP changes — pure JS DOM-event compatibility fix.
  • Pre-existing ESLint baseline preserved (no new violations introduced).
  • assets/js/functions.min.js is regenerated because .min.js files are
    tracked in this repo (despite the general AGENTS.md guideline), so the
    fix must ship the rebuilt minified bundle to take effect at runtime.
    Ref [Bug] Setup Wizard > Your Company #116


Merged via PR #1193 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).


aidevops.sh v3.15.38 spent 29s on this as a headless bash routine.

@github-actions
Copy link
Copy Markdown

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: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 37.78 MB 810.00 ms (-49.00 ms / -6% ) 184.50 ms (+21.00 ms / +11% ) 1005.50 ms (-59.50 ms / -6% ) 1926.00 ms (-46.00 ms / -2% ) 1841.35 ms 88.50 ms (-7.25 ms / -8% )
1 56 49.14 MB 936.50 ms 144.50 ms (-4.00 ms / -3% ) 1087.50 ms 2076.00 ms 1995.50 ms 82.50 ms

@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant