Skip to content

Commit aee330f

Browse files
authored
Fix Borders in Outlined Button Group in textanswers view (#2085)
* 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 0c1796e commit aee330f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-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/_adjustments.scss

+21
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,24 @@ $alert-colors: (
133133
border-color: $input-focus-border-color;
134134
box-shadow: $input-focus-box-shadow;
135135
}
136+
137+
// Change .btn-group outlined border style to fix double borders with outlined button style
138+
// see https://github.com/twbs/bootstrap/issues/25888
139+
.btn-group.outline-fix {
140+
141+
// If .btn is not the last element in the group, remove the right border.
142+
// Also uses :has to not remove the right border if the next element is a disabled input
143+
.btn:not(:last-child):has(+ :not(.btn-check[disabled])) {
144+
border-right: 0;
145+
}
146+
147+
// Explicitly disable the left border of disabled .btn's to use the right border of the previous button.
148+
.btn-check[disabled] + .btn {
149+
border-left: 0;
150+
}
151+
152+
// Revert Bootstrap's hack, that uses negative margin which would appear as double borders
153+
:not(.btn-check:first-child) + .btn {
154+
margin-left: unset;
155+
}
156+
}

0 commit comments

Comments
 (0)