remi icon indicating copy to clipboard operation
remi copied to clipboard

css classes duplicates when using add_class

Open batzkass opened this issue 6 years ago • 4 comments

Hi Remi,

I usually use add_class() and remove_class() on Widget objects to style my objects depending on various events. However, when an action using add_class() is triggered multiple times, the class is added at each call, resulting in duplicates and preventing me from actually removing the class with remove_class() When using add_class, I would expect that the class is only added if it doesn't already exist to fix this, as corrected in the attached patch.

Regards, Francois

patch.txt

batzkass avatar Dec 17 '18 12:12 batzkass

Hello @batzkass, why you don't simply call remove_class before each add_class? And however you can access the widget._classes array to manipulate directly

dddomodossola avatar Dec 21 '18 10:12 dddomodossola

Hi Davide

It would simplify the developpers scripts with a single call. Anyway I added a function that do it, I just thought to others devs.

Le ven. 21 déc. 2018 à 11:24, Davide Rosa [email protected] a écrit :

Hello @batzkass https://github.com/batzkass, why you don't simply call remove_class before each add_class? And however you can access the widget._classes array to manipulate directly

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dddomodossola/remi/issues/259#issuecomment-449349801, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhDwHEyYZ2pxYLFsGsWBZUqRsrzVh91ks5u7LbtgaJpZM4ZWOPZ .

batzkass avatar Dec 21 '18 11:12 batzkass

@batzkass I thank you for the suggestion, I will make this change in the future ;-)

dddomodossola avatar Dec 21 '18 13:12 dddomodossola

@batzkass, why not do everyone a favour and submit a pull request? ;)

alensiljak avatar Apr 05 '19 21:04 alensiljak