sveltestrap icon indicating copy to clipboard operation
sveltestrap copied to clipboard

Feedback attribute breaks InputGroups

Open Meknassih opened this issue 3 years ago • 1 comments

Hi, I just noticed that adding a feedback attribute for validation purposes to an Input breaks it from its suffix element in an InputGroup.

I have noticed that changing the order of the elements fixes the issue.

Generated HTML (broken) :

<div class="input-group">
    <input id="totalWeight" class="form-control is-invalid" type="text" name="" placeholder="100">
    <div class="invalid-feedback">Ce champ est obligatoire</div>
    <span class="input-group-text">kg</span>
</div>

image

Working HTML (fixed by swapping div.invalid-feedback and span.input-group-text) :

<div class="input-group">
    <input id="totalWeight" class="form-control is-invalid" type="text" name="" placeholder="100">
    <span class="input-group-text">kg</span>
    <div class="invalid-feedback">Ce champ est obligatoire</div>
</div>

image

Meknassih avatar Dec 04 '21 18:12 Meknassih

Ah thanks @Meknassih - hmm that's a tough one to fix since the feedback would be rendered by the Input, and can't split the elements like that. Am assuming this is the best workaround for now:

<InputGroup>
    <Input id="totalWeight" invalid placeholder="100" />
    <InputGroupText>kg</InputGroupText >
   <FormFeedback>Ce champ est obligatoire</FormFeedback>
</InputGroup >

I'll look and see if some better option, thanks for the heads up.

bestguy avatar Jan 01 '22 03:01 bestguy