Skip to content

Conversation

SebSept
Copy link
Contributor

@SebSept SebSept commented Oct 2, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

fix #21230

@SebSept SebSept changed the title Application of validation template applies all users Application of validation template applies all users - fix #21230 Oct 2, 2025
@SebSept SebSept added this to the 11.0.1 milestone Oct 3, 2025
@cedric-anne cedric-anne added the bug label Oct 6, 2025
Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

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

As this issue may affect any dropdown, a global fix should be made to make the setValue handlers compatible with multiple values.

@cedric-anne cedric-anne modified the milestones: 11.0.1, 11.0.2 Oct 7, 2025
@cconard96
Copy link
Contributor

I didn't manage to fix the issue in core. I don't know why,

glpi/js/common.js

Line 1907 in daa142c

select2_el.bind('setValue', (e, value) => {

always receive the fist element of the array and not the passed array.

As I mentioned in the bug report, An array of data can be passed so it doesn't see the list of users as a single parameter.
https://api.jquery.com/trigger/

The trigger function takes an event as the first parameter. The second parameter is either a single value or an array of values to pass to the event handler. When the even handler is called, those extra values are passed as separate parameters.

You can see this yourself from the browser console:

$(window).on('myevent', (e, test1, test2, test3) => { console.log({test1, test2, test3}) } 
$(window).trigger('myevent', ["value1", "value2", "value3"]);

If you want to actually pass an array as a single value, it needs wrapped in another array:

$(window).trigger('myevent', [["value1", "value2", "value3"]]);

@SebSept
Copy link
Contributor Author

SebSept commented Oct 14, 2025

thanks @cconard96 but I finally used the ... operator to group all parameters in a single argument which is always an array (makes the received arguments consistent).

@SebSept SebSept force-pushed the fix-approval-template branch from 4441775 to eb10540 Compare October 15, 2025 07:45
Application of validation template applies all users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Approval template doesn't add all users when using on a ticket

3 participants