Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when setting disabled prop via function #54

Open
MasterPuffin opened this issue Mar 6, 2025 · 1 comment
Open

Issue when setting disabled prop via function #54

MasterPuffin opened this issue Mar 6, 2025 · 1 comment

Comments

@MasterPuffin
Copy link

I have the following setup

<div id="container">
    <div :each="field in fields">
        <input type="text" :name="field.name" :disabled="field.disabled">
    </div>
</div>
const fields = [
    {
        name: "Test 1",
        disabled: true,
    },
    {
        name: "Test 2",
        disabled: false,
    },
    {
        name: "Test 3",
        disabled: (option) => {
            return true
        },
    },
    {
        name: "Test 4",
        disabled: (option) => {
            return false
        },
    }
]


const container = document.querySelector('#container')

const state = sprae(container, {
    fields: fields,
})

Test 1 is disabled, Test 2 is enabled, Test 3 is disabled, however Test 4 is disabled even though it should be enabled.

@dy
Copy link
Owner

dy commented Mar 6, 2025

I think you should do ":disabled=field.disabled?.call?.()" because you switch between boolean and function. Attribute doesn't call function value by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants