R
R
runprogr2020-06-14 15:11:09
JavaScript
runprogr, 2020-06-14 15:11:09

Why do css styles remain after dynamic class change?

Strange situation, please tell me which way to dig.
There is a code

<input type="checkbox" 
                    v-model="form.gameCodes"
                    name="gameCodes"
                    value="1"
                    class="game-tab__checkbox"
                    id="anyid">
<label for="anyid" class="game-tab game-tab_register" :class="{ active : form.gameCodes.includes('1') }">
</label>

There is a checkbox, when clicked, its value gets into the array. The label has a condition that if the array contains the desired value, then the active class is added to it (and the styles change accordingly).
On the desktop version of the site, when you click on the label, a class with styles is added, when you click again, the class and styles are immediately removed, as it should be.
On the mobile version of the site, when you click on the label, a class with styles is added, when you click again, the class is immediately removed, BUT the styles of this class remain. Until you click again somewhere else on the site, at that moment the styles disappear.
Why is the class removed, but its styles remain? Why is this only happening on mobile? What can cause such behaviour?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
runprogr, 2020-06-14
@runprogr

Suddenly found the cause of the problem. In the mobile version of the site, when you click on an element, the :hover effect worked and was active all the time until you clicked somewhere else. I had to leave the hover in the desktop version, but remove the hover effect from the styles of the mobile version and the problem was solved.
Hope it helps someone in a similar situation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question