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

is-danger isn't being propagated from Field to Input class #56

Closed
asm0dey opened this issue May 10, 2020 · 4 comments · Fixed by #130
Closed

is-danger isn't being propagated from Field to Input class #56

asm0dey opened this issue May 10, 2020 · 4 comments · Fixed by #130
Labels
bug Something isn't working

Comments

@asm0dey
Copy link

asm0dey commented May 10, 2020

I'm trying to use svelma with Svelte forms lib (https://github.com/tjinauyeung/svelte-forms-lib).

I have following field:

<Field label="Password" type={!!$errors.password?"is-danger":""} message="{$errors.password}">
	<Input
					bind:value={$form.password}
					passwordReveal="true"
					type="password"
					name="password"
					on:change={handleChange}/>
</Field>

When entered password is invalid rendered html looks like this:

<div message="this must be at least 6 characters" class="field is-danger svelte-utp4kb">
	<label for="" class="label">Password</label>
	<div class="control svelte-1v5s752 has-icons-right">
		<input name="password" type="password" class="input svelte-1v5s752">
		<span class="icon has-text-primary is-right is-clickable"><i class="fas fa-eye  "></i></span>
	</div>
	<p class="help is-danger svelte-utp4kb">this must be at least 6 characters</p>
</div>

As you can see is-danger class isn't being propagated to input, which leads to rendering red border.

@asm0dey asm0dey changed the title is-danger isn't being propagatet from Field to Input class is-danger isn't being propagated from Field to Input class May 10, 2020
@c0bra c0bra added the bug Something isn't working label May 13, 2020
@sharpcodepro
Copy link

Observing the same issue. In my understanding, this happens because the type in Input component is retrieved with getContext. Per Svelte documentation "Since context is not reactive, values that change over time should be represented as stores".

@abbychau
Copy link
Collaborator

abbychau commented Apr 14, 2021

seems that svelte/store is needed for this feature

@saravanabalagi
Copy link
Contributor

We can put a store in the context and subscribe to it.

@MeXaaR
Copy link

MeXaaR commented May 12, 2022

We can put a store in the context and subscribe to it.

Have you tried that solution ? because I can't make it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants