Subscribe on changes!

disabled attribute problem

avatar
Sep 24th 2021

Version

3.2.16

Reproduction link

codesandbox.io

Steps to reproduce

Open the aforementioned link with a device with a rear camera

What is expected?

The button should be clickable on a device with a rear camera, should be disabled and not clickable on other devices

What is actually happening?

The button is not clickable regardless the device used


The same template is working in Vue 2 (https://jsfiddle.net/lmartini/u9dLp62g/10/). It seems that disabled="false" is not enough in order to enable the label. The label is enabled if I set disabled to undefined instead. Am I missing something or is this an issue?

avatar
Sep 24th 2021

In Vue 3, you need to set any non-boolean attribute to null or undefined to have it removed.

See: https://v3.vuejs.org/guide/migration/attribute-coercion.html#_2-x-syntax

avatar
Sep 24th 2021

Hm, disabled is a boolean attribute so false should work ...

avatar
Sep 24th 2021

Ah. You are talking about the disabled attribute when set on <label>.

Labels don't really have a disabled attribute (see MDN), so it's not recognized by Vue as a boolean attribute. Thus, as mentioned above, it can only be removed with null.