N°9628 - Fix issue following 5b9e0a1d being applied to non-jQuery elements#961
N°9628 - Fix issue following 5b9e0a1d being applied to non-jQuery elements#961steffunky wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes issue N°9628 by reverting parts of commit 5b9e0a1. That earlier commit adapted several call sites for jQuery 3.4 (e.g. .submit() → .trigger('submit'), .focus() → .trigger('focus'), form:first → form).first()), but some of the changes were applied to non-jQuery targets (native DOM form elements, the native Window object returned by window.open, and CKEditor 5 view objects), causing JS errors or incorrect behavior. The changes restore the appropriate native/framework API on those elements while keeping the jQuery 3.4 fix where the target genuinely is a jQuery object.
Changes:
- Restore native
HTMLFormElement.submit()on the class-selector dropdowns inUniversalSearch.phpandtagadmin.php. - Restore native
Window.focus()in the OAuth client popup handler, and CKEditor 5'sview.change(writer => ...)API in the CKEditor handler. - Keep the jQuery 3.4 fix in the select template by switching
parents('form:first')toparents('form').first()(target is a real jQuery object).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/base/components/input/select/select.html.twig | Uses parents('form').first() on a jQuery object, correctly retaining the jQuery 3.4 fix |
| pages/UniversalSearch.php | Reverts to native this.form.submit() on a DOM form element |
| pages/tagadmin.php | Reverts to native this.form.submit() on a DOM form element |
| js/ckeditor.handler.js | Restores CKEditor 5 view.change(writer => ...) instead of the incorrect .on('change', ...) |
| datamodels/2.x/itop-oauth-client/assets/js/oauth_connect.js | Restores native Window.focus() on the window.open reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // - Width | ||
| if (aConfiguration.width !== undefined) { | ||
| editor.editing.view.on('change', writer => { writer.setStyle( 'width', aConfiguration.width, editor.editing.view.document.getRoot() ); } ); | ||
| editor.editing.view.change( writer => { writer.setStyle( 'width', aConfiguration.width, editor.editing.view.document.getRoot() ); } ); |
| we bring such window back on top/in front of its parent window. */ | ||
| oWindowObjectReference = window.open(url, name, sWindowFeatures); | ||
| oWindowObjectReference.trigger('focus'); | ||
| oWindowObjectReference.focus(); |
|
| Filename | Overview |
|---|---|
| datamodels/2.x/itop-oauth-client/assets/js/oauth_connect.js | Correctly replaces jQuery .trigger('focus') with native Window.focus() on the object returned by window.open(); minor indentation inconsistency (tabs→spaces) in the two new lines. |
| js/ckeditor.handler.js | Replaces view.on('change', writer => {...}) — which passed an EventInfo object (not a writer) to the callback and therefore always threw — with the correct CKEditor 5 view.change(writer => {...}) API; indentation inconsistency in new lines. |
| pages/UniversalSearch.php | Fixes this.form.trigger('submit') (jQuery method on a native HTMLFormElement) to this.form.submit() — correct native DOM call. |
| pages/tagadmin.php | Same fix as UniversalSearch.php — replaces this.form.trigger('submit') with the native this.form.submit(). |
| templates/base/components/input/select/select.html.twig | Correctly moves :first from inside the CSS selector string to the jQuery .first() method, fixing a jQuery 3.4+ deprecation while keeping .trigger('submit') valid (the element is still wrapped in $()). |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Commit 5b9e0a1d\n(jQuery 3.4 compat)"] -->|"Overapplied to non-jQuery objects"| B["Bug: .trigger() / .on() on native objects"]
B --> C1["oauth_connect.js\nwindow.open() → Window object\n.trigger('focus') ❌"]
B --> C2["ckeditor.handler.js\nEditingView.on('change', writer)\nEventInfo ≠ DowncastWriter ❌"]
B --> C3["UniversalSearch.php / tagadmin.php\nthis.form → HTMLFormElement\n.trigger('submit') ❌"]
B --> C4["select.html.twig\n$(this).parents('form:first')\n:first deprecated in jQuery 3.4 ⚠️"]
C1 -->|"This PR"| F1["Window.focus() ✅"]
C2 -->|"This PR"| F2["view.change(writer => {...}) ✅"]
C3 -->|"This PR"| F3["this.form.submit() ✅"]
C4 -->|"This PR"| F4[".parents('form').first() ✅"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["Commit 5b9e0a1d\n(jQuery 3.4 compat)"] -->|"Overapplied to non-jQuery objects"| B["Bug: .trigger() / .on() on native objects"]
B --> C1["oauth_connect.js\nwindow.open() → Window object\n.trigger('focus') ❌"]
B --> C2["ckeditor.handler.js\nEditingView.on('change', writer)\nEventInfo ≠ DowncastWriter ❌"]
B --> C3["UniversalSearch.php / tagadmin.php\nthis.form → HTMLFormElement\n.trigger('submit') ❌"]
B --> C4["select.html.twig\n$(this).parents('form:first')\n:first deprecated in jQuery 3.4 ⚠️"]
C1 -->|"This PR"| F1["Window.focus() ✅"]
C2 -->|"This PR"| F2["view.change(writer => {...}) ✅"]
C3 -->|"This PR"| F3["this.form.submit() ✅"]
C4 -->|"This PR"| F4[".parents('form').first() ✅"]
Reviews (1): Last reviewed commit: "N°9628 - Fix issue following 5b9e0a1d be..." | Re-trigger Greptile
Base information
Symptom (bug) / Objective (enhancement)
Some changes made to support jQuery 3.4 were applied to non jQuery elements, leading to js errors or weird behaviour.
Cause (bug)
5b9e0a1 was commited without checking if every instance modifies were jQuery elements
Proposed solution (bug and enhancement)
Revert changes for some elements, or apply 5b9e0a1 to elements that have changed since to accommodate behaviour changes
Checklist before requesting a review