Skip to content

Commit 2f27865

Browse files
committed
add .outline-fix class for .btn-group
This class replaces bootstraps default strategy of using negative margins to hide double borders with specific css-selectors that hide and show specific borders.
1 parent 0b2b04a commit 2f27865

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

evap/staff/templates/staff_evaluation_textanswers_section.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<input type="hidden" name="answer_id" value="{{ answer.id }}" />
3737

38-
<div class="btn-group btn-group-sm" role="group">
38+
<div class="btn-group btn-group-sm outline-fix" role="group">
3939
<input type="radio" class="btn-check" name="action" value="publish" id="{{ answer.id }}-radio-publish" autocomplete="off" {% if answer.will_be_public %}checked{% endif %}>
4040
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-publish">{% trans 'Publish' %}</label>
4141

evap/static/scss/components/_button-group.scss

+22
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,25 @@ div.vote-inputs > textarea {
1717
div.vote-inputs label.choice-error {
1818
border-color: $evap-red;
1919
}
20+
21+
// Change .btn-group outlined border style to fix double borders with outlined button style
22+
// see https://github.com/twbs/bootstrap/issues/25888
23+
.btn-group.outline-fix {
24+
25+
// If .btn is not the last element in the group, remove the right border.
26+
// Also uses :has to not remove the right border if the next element is a disabled input
27+
.btn:not(:last-child):not(.dropdown-toggle):has(+ :not(.btn-check[disabled])), .btn-group:not(:last-child) > .btn {
28+
border-right: 0;
29+
}
30+
31+
// Explicitly disable the left border of disabled .btn's to use the right border of the previous button.
32+
.btn-check[disabled] + .btn {
33+
border-left: 0;
34+
}
35+
36+
// Revert Bootstrap (Prevent double borders when buttons are next to each other)
37+
> :not(.btn-check:first-child) + .btn,
38+
> .btn-group:not(:first-child) {
39+
margin-left: unset;
40+
}
41+
}

0 commit comments

Comments
 (0)