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

Radio button groups are not working after migrating TheAdmin theme from BS4 to BS5 #11703

Closed
MikeAlhayek opened this issue May 14, 2022 · 4 comments
Milestone

Comments

@MikeAlhayek
Copy link
Member

MikeAlhayek commented May 14, 2022

Describe the bug

When using Radio button group in the Admin theme, selecting a radio button does not select.

To Reproduce

Steps to reproduce the behavior:
Create a view anywhere in admin using TheAdmin theme and place the following HTML code

<form>
            <div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
               <div class="btn-group btn-group-sm me-2" role="group" aria-label="Sort">
                  <input type="radio" class="btn-check" value="Profit" id="Sort_ByProfit" autocomplete="off" checked="checked" data-val="true" data-val-required="The By field is required." name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByProfit">Profit</label>
                  <input type="radio" class="btn-check" value="Year" id="Sort_ByYear" autocomplete="off" name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByYear">Year</label>
                  <input type="radio" class="btn-check" value="Cost" id="Sort_ByCost" autocomplete="off" name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByCost">Cost</label>
                  <input type="radio" class="btn-check" value="Odometer" id="Sort_ByOdometer" autocomplete="off" name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByOdometer">Odometer</label>
                  <input type="radio" class="btn-check" value="Status" id="Sort_ByStatus" autocomplete="off" name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByStatus">Status</label>
                  <input type="radio" class="btn-check" value="DaysInStock" id="Sort_ByDaysInStock" autocomplete="off" name="Sort.By">
                  <label class="btn btn-outline-secondary" for="Sort_ByDaysInStock">Days In Stock</label>
               </div>
               
            </div>
</form>

Now run the app and click on any of the radio buttons, you'll notice that the button do not appear selected. This works perfectly fine in other themes like TheTheme theme from the front end.

Expected behavior

When you click on the radio button, it should appear darker "selected"

Screenshots

Here is a screen cast of TheAdmin theme where it does not stay selected as well as TheTheme theme in the front end with the expected behavior

group-button-not-working

@agriffard @Skrypt

@Skrypt
Copy link
Contributor

Skrypt commented May 16, 2022

This is a button "active" state behavior that can be seen by going to the browser dev tools and checking the :active state of the element. As you can see the styles are working appropriately. The issue is that the state is not toggled on the "click" event of the buttons.

<script at="foot">
$(document).ready(function(){
    $(".btn").click(function(){
        $(this).button("toggle");
    });
});
</script>

Adding this script to your page will make it work in the admin. Though, I don't understand the difference between the admin and the frontend themes here. I removed every javascript links in TheAdmin to test this and the active state is still not triggered by clicking on the button elements.

@sebastienros sebastienros added this to the 1.x milestone May 19, 2022
@MikeAlhayek
Copy link
Member Author

@Skrypt neither of the following worked

<script at="Foot">
    $(document).ready(function() {
        $(".btn").click(function() {
            $(this).button("toggle");
        });
    });
</script>

or

<script at="Foot">
    $(document).ready(function() {
        $(".btn-check").click(function() {
            $(this).button("toggle");
        });
    });
</script>

I also attempted to add data-bs-toggle="button" element to each radio input. This adds the active class to each input but the color of it does not change. Bootstrap 5.1 example does not show that the element data-bs-toggle="button" is needed.

@Skrypt
Copy link
Contributor

Skrypt commented May 24, 2022

Ok, I found out how to fix the issue. Though it will break the darkmode admin theme. Need to try different things and evaluate if it is worth it. The issue is that we have a darkmode which is not fully supported by Bootstrap 5. It should be fully supported by Bootstrap 6.

orchard.mp4

Here is what I tried :

image

@MikeAlhayek
Copy link
Member Author

This was fixed after migration to BS 5.3!

@MikeAlhayek MikeAlhayek modified the milestones: 1.x, 1.8 Jan 2, 2024
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

3 participants