Multiple coloriswidget form elements in custom form do not respect each field settings

Created on 3 October 2024, about 1 month ago

Problem/Motivation

Using several form element "coloriswidget" in a custom form, with each fields having their own different settings (swatches, cancel button etc...), every Coloris instance the settings from the latest field.

Steps to reproduce

Create a custom form using multiple "coloriswidget" fields with their own settings different, display the custom form and see that all coloris fields using the same settings as the latest field of the form.

Proposed resolution

I managed to make it work by adding, in the javascript file, an extra addEventListener 'onclick' on each coloris instance to recreate the coloris Object using the correct settings :

 el.addEventListener('click', e => {
        Coloris(settings);
});

Coloris(settings);

I think it is related to theat comment on Coloris library page : https://github.com/mdbassit/Coloris?tab=readme-ov-file#simulating-multip...

Apparently reacreating the instance on click on the textfield is taking in account the correct settings.

Remaining tasks

Check the proposed solution and test it in different usage contexts.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland grumpy74 Geneva, CH 🇨🇭

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024