easy-toggle-state icon indicating copy to clipboard operation
easy-toggle-state copied to clipboard

Add a default state attribute for target elements

Open fredmef opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. I'm always frustrated when I need to wait the initialization of the triggers to have the default state of the target elements. This behavior creates some glitchs or layout shifting which provides a bad user experience.

Describe the solution you'd like Can it be possible to have an attribute like data-toggle-is-active (eg: data-toggle-target-is-active) for the target elements to avoid waiting initialization to have the default state for target elements ?

Describe alternatives you've considered None.

Additional context None.

fredmef avatar Jun 02 '22 12:06 fredmef

I think a slightly better approach, would be to use an "active" class already set in the html which can then be toggled by clicking a trigger. I.e Add .is-active to both the trigger and the "active" target. Then on initialisation the js has the smarts to know that if the trigger and target are "active" don't trigger the active state, but allow for further toggling i.e if it's a tabs/accordion component etc. I want to provide a basic test case, but I don't have the time atm.

aaronstezycki avatar Jun 27 '22 11:06 aaronstezycki

... but yeah, currently this can create large layoutshifts on load and needs fixing asap I think.

aaronstezycki avatar Jun 27 '22 11:06 aaronstezycki