question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Putting v-can on a button component causes the disabled attribute to be lost

See original GitHub issue

I have a component like this:

<template>
    <button
        class="inline-block font-bold py-2 px-4 rounded text-xs bg-gray-200 text-600"
        :type="type"><slot>Save</slot></button>
</template>

If I import it into another component as SecondarySaveButton, then putting a v-can directive on it oddly causes the disabled attribute to be lost:

<secondary-save-button
    v-can:tag-suggestions
    name="save_tag"
    :disabled="!canSubmitSuggestion">Add and tag</secondary-save-button>

If I wrap the component with a v-can statement, the disabled attribute is rendered as expected:

<span v-can:tag-suggestions>
    <secondary-save-button
        name="save_tag"
        :disabled="!canSubmitSuggestion">Add and tag</secondary-save-button>
</span>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thomaslichtdotnetcommented, Oct 14, 2021

The disabled attribute is always initialized with false (index.ts line 230). After commenting this line it was working for me.

But I don’t know if this causes other side effects.

      const el_ = el as LooseHTMLElement
      // el_.disabled = false
      el_.readOnly = false`
0reactions
mblarsencommented, Oct 24, 2021

Published version 0.15.4 with fix by @thomaslichtdotnet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing disabled attribute to an HTML element in a child ...
I found a solution in the last answer here: How to disable/hide a button as soon as clicked in Blazor? Even though SubmitSearch...
Read more >
The Disabled Attribute in React Buttons - Upmostly
Disabled is an attribute passed to React buttons. This means that it is passed into button components within JSX. In App.js: App.js.
Read more >
HTML attribute: disabled - HTML: HyperText Markup Language
The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can ...
Read more >
Exploring the difference between disabling a form control ...
Exploring the difference between disabling a form control through reactive forms API and HTML attributes. Having parts of a form disabled is a...
Read more >
Making Disabled Buttons More Inclusive - CSS-Tricks
This button is disabled by the disabled attribute. (Note that this is a boolean attribute, which means that it can be written as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found