Angular playground

Nova v3.38.0

Preview

Angular

Boolean attributes on form components

disabled="false" now disables a form component. Remove the attribute or pass a Boolean.

Form components now read a Boolean attribute the way HTML does: if the attribute is there, the value is true, whatever text it holds. <nv-fieldtext disabled="false"> is disabled. Before, Nova read the text "false" as false.

The change came with the upgrade to Stencil 4.45, which treats Boolean attributes on form-associated components like those of native form controls.

Which components#

Every Boolean property of these form components, for example disabled, readonly, required, checked, error and fluid:

nv-button, nv-iconbutton, nv-dialogfooter, nv-drawerfooter, nv-fieldcheckbox, nv-fielddropdown, nv-fieldmultiselect, nv-fieldnumber, nv-fieldpassword, nv-fieldradio, nv-fieldselect, nv-fieldslider, nv-fieldtext, nv-fieldtextarea, nv-fieldtime, nv-fileupload and nv-toggle.

Two exceptions keep reading "false" as false:

  • aria-required="false" still means not required. It is an ARIA attribute, whose value is a word, not a Boolean.
  • nv-fielddate and nv-fielddaterange are not form-associated, so their attributes behave as before.

What to change#

Remove the attribute when the value is false.

Old usage:

html<nv-fieldtext label="Name" disabled="false" required="false"></nv-fieldtext>

New usage:

html<nv-fieldtext label="Name"></nv-fieldtext>

If the value changes at runtime, set the property instead of the attribute:

javascriptconst field = document.querySelector('nv-fieldtext');
field.disabled = false;
// Or remove the attribute
field.removeAttribute('disabled');

Do not write setAttribute('disabled', 'false'): it disables the field.

Framework wrappers#

Bindings that pass a real Boolean are not affected:

  • React: disabled={false}
  • Vue: :disabled="false"
  • Angular: [disabled]="false"
  • Blazor: Disabled="false"

Look for places that pass the text "false" instead, such as a static Angular attribute without brackets (disabled="false"), a Vue attribute without the colon, or server-rendered HTML that prints the value of a Boolean. Bind a Boolean there, or leave the attribute out.