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

[HELP] Incorrect Height #192

Closed
SoftCircuits opened this issue Sep 5, 2024 · 5 comments
Closed

[HELP] Incorrect Height #192

SoftCircuits opened this issue Sep 5, 2024 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@SoftCircuits
Copy link

SoftCircuits commented Sep 5, 2024

I have the following markup.

<div class="row">
    <div class="col-md-12">
        <div class="mb-3">
            <label asp-for="AddTransfer.IsStorage"></label>
            <input asp-for="AddTransfer.IsStorage" type="checkbox" class="form-control" data-toggle="toggle"
                    data-offlabel="Railcar" data-onlabel="Storage"
                    data-offstyle="success" data-onstyle="danger"
                    data-width="100%" />
        </div>
    </div>
</div>

Here's the generated HTML.

<div class="row">
    <div class="col-md-12">
        <div class="mb-3">
            <label id="AddTransfer_IsStorageLabel" for="AddTransfer_IsStorage">Source Type</label>
            <div class="toggle btn btn-success off" data-toggle="toggle" role="button" tabindex="0"
                style="width: 100%; min-height: 0px;">
                <input type="checkbox" class="form-control" data-toggle="toggle"
                    data-offlabel="Railcar" data-onlabel="Storage"
                    data-offstyle="success" data-onstyle="danger"
                    data-width="100%" data-val="true"
                    data-val-required="The IsStorage field is required." id="AddTransfer_IsStorage"
                    name="AddTransfer.IsStorage" value="true">
                <div class="toggle-group">
                    <span class="btn btn-danger toggle-on">Storage</span>
                    <span class="btn btn-success toggle-off">Railcar</span> 
                    <span class="toggle-handle btn"></span>
                </div>
            </div>
        </div>
    </div>
</div>

It functions correctly, but the control height is not tall enough.

image

I have a similar button elsewhere in my project. I copied that code. So it should work. It seemed like I may have had the same issue with the other code but can't remember how I resolved it.

If you look at the div created by the control, you can see style="width: 100%; min-height: 0px;" On the other version that works, it has min-height set to 38px. But I don't understand why.

Why doesn't it set the correct height? And what do I need to do about it?

Note: I was using bootstrap5-toggle v5.0.6, but upgraded to v5.1.1 and there was no difference.

@SoftCircuits SoftCircuits added the help wanted Extra attention is needed label Sep 5, 2024
@SoftCircuits
Copy link
Author

@palcarazm Is there anyone that could look at this issue? It seems like I'm just doing basic functionality here. I would have thought this would be rock solid.

@palcarazm
Copy link
Owner

Hi you can use rerender method from JavaScript to set correct height to toggle.

In fact this occurs when toggle is render in a not visible section.

@SoftCircuits
Copy link
Author

@palcarazm

Hi you can use rerender method from JavaScript to set correct height to toggle.

In fact this occurs when toggle is render in a not visible section.

Thanks. In fact, this is on a modal popup. So it is not visible when the page is displayed.

I am not familiar with rerender, and I seem to be having trouble finding it. Do you happen to have a link?

@palcarazm
Copy link
Owner

@palcarazm

Hi you can use rerender method from JavaScript to set correct height to toggle.

In fact this occurs when toggle is render in a not visible section.

Thanks. In fact, this is on a modal popup. So it is not visible when the page is displayed.

I am not familiar with rerender, and I seem to be having trouble finding it. Do you happen to have a link?

Is a bootstrap-toggle method https://github.com/palcarazm/bootstrap5-toggle#methods

@SoftCircuits
Copy link
Author

@palcarazm Yes, I got that working. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants