mdgriffith / elm-ui

What if you never had to write CSS again?
https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/
BSD 3-Clause "New" or "Revised" License
1.34k stars 110 forks source link

Pseudo-classes are triggered randomly (hover/mouseOver, focus/focused, active/mouseDown) #352

Open XOMAv2 opened 1 year ago

XOMAv2 commented 1 year ago

Bug!

If an element is in several states (:hover, :focus, :active), and it contains a set of attributes for each of these states (Element.mouseOver, Element.focused, Element.mouseDown), then one of the conflicting states will be selected randomly.

Steps to reproduce

  1. Several elements are defined in the markup.
  2. Elements use several identical pseudo-classes, for example, Element.mouseOver and Element.mouseDown.
  3. Within the element, pseudo-classes are defined in different order.
  4. Pairs of identical pseudo-classes affect the same attributes with the same values.

Ellie example

Causes of the bug

The elements will have 100% identical CSS classes, but they will be written to the intermediate stylesheet in a different order, and at the end, duplicates will also be removed. If several conflicting events occur (:hover, :focus, :active) according to CSS rules, the selector defined later will be applied.

Expected behavior

Ideal scenario: each element gets a set of unique classes that are applied in the order they are listed in the attribute list. Alternative scenario: the order of application of pseudo-classes is strictly fixed (:hover < :focus < :active).

Versions

XOMAv2 commented 1 year ago

bug #has-ellie