Skip to content

N°9628 - Fix issue following 5b9e0a1d being applied to non-jQuery elements#961

Open
steffunky wants to merge 1 commit into
developfrom
issue/9628-universal-search-broken
Open

N°9628 - Fix issue following 5b9e0a1d being applied to non-jQuery elements#961
steffunky wants to merge 1 commit into
developfrom
issue/9628-universal-search-broken

Conversation

@steffunky

Copy link
Copy Markdown
Member

Base information

Question Answer
Related to a SourceForge thread / Another PR / A GitHub Issue / Combodo ticket? N°9628
Type of change? Bug fix

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

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand without digging in the code?

@steffunky steffunky added this to the 3.3.0 milestone Jul 7, 2026
@steffunky steffunky self-assigned this Jul 7, 2026
@steffunky steffunky added the internal Work made by Combodo label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:firstform).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 in UniversalSearch.php and tagadmin.php.
  • Restore native Window.focus() in the OAuth client popup handler, and CKEditor 5's view.change(writer => ...) API in the CKEditor handler.
  • Keep the jQuery 3.4 fix in the select template by switching parents('form:first') to parents('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.

Comment thread js/ckeditor.handler.js
// - 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();
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects five sites where commit 5b9e0a1d (jQuery 3.4 compatibility) mistakenly applied jQuery-specific APIs to plain DOM/native objects, causing runtime TypeErrors or silent failures.

  • oauth_connect.js: replaces jQuery .trigger('focus') with the native Window.focus() on the object returned by window.open().
  • ckeditor.handler.js: replaces the broken view.on('change', writer => {...}) (which passed an EventInfo object—not a DowncastWriter—to the callback) with the correct CKEditor 5 view.change(writer => {...}) API, called once at initialization.
  • UniversalSearch.php / tagadmin.php: replaces this.form.trigger('submit') with the native HTMLFormElement.submit(), since this.form is a plain DOM element, not a jQuery wrapper.
  • select.html.twig: keeps the jQuery wrapper but moves :first from inside the CSS selector string to the .first() jQuery method, the correct jQuery 3.4+ form while preserving the .trigger('submit') call on the jQuery object.

Confidence Score: 4/5

Safe to merge; all five changes correctly replace jQuery-API calls on non-jQuery objects with their native or proper-framework equivalents.

Every fix is a straightforward and well-scoped correction of clearly broken code. The only open items are two indentation inconsistencies (tabs vs. spaces in the new lines of oauth_connect.js and ckeditor.handler.js) that have no runtime impact.

oauth_connect.js and js/ckeditor.handler.js have minor whitespace inconsistencies in the new lines; all other files are clean.

Important Files Changed

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() ✅"]
Loading
%%{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() ✅"]
Loading

Reviews (1): Last reviewed commit: "N°9628 - Fix issue following 5b9e0a1d be..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants