Skip to content

Commit ae2cce9

Browse files
authored
fix(b-form-spinbutton): prevent buttons from re-ordering when parent element is RTL (bootstrap-vue#4802)
* chore(spinbuttons): prevent buttons from re-ordering when parent element * Update form-spinbutton.js * Update form-spinbutton.spec.js
1 parent f825778 commit ae2cce9

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

src/components/form-spinbutton/_spinbutton.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
height: auto;
1010
width: auto;
1111
}
12+
13+
@at-root {
14+
// Prevent the buttons from reversing order on in horizontal RTL mode
15+
[dir="rtl"] &:not(.flex-column),
16+
&[dir="rtl"]:not(.flex-column) {
17+
flex-direction: row-reverse;
18+
}
19+
}
1220

1321
output {
1422
font-size: inherit;

src/components/form-spinbutton/form-spinbutton.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,7 @@ export const BFormSpinbutton = /*#__PURE__*/ Vue.extend({
546546
...this.$attrs,
547547
role: 'group',
548548
lang: this.computedLocale,
549-
tabindex: isDisabled ? null : '-1',
550-
// We want to keep the order of the buttons regardless
551-
// of locale (flex will re-order based on rtl/ltr)
552-
dir: 'ltr'
549+
tabindex: isDisabled ? null : '-1'
553550
},
554551
on: {
555552
keydown: this.onKeydown,

src/components/form-spinbutton/form-spinbutton.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ describe('form-spinbutton', () => {
1717
expect(wrapper.classes()).toContain('align-items-stretch')
1818
expect(wrapper.attributes('role')).toEqual('group')
1919
expect(wrapper.attributes('tabindex')).toEqual('-1')
20-
// We always have LTR to ensure the flex order stays ltr
21-
expect(wrapper.attributes('dir')).toEqual('ltr')
2220

2321
// Should have 3 child elements (btn, output, btn)
2422
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
@@ -77,8 +75,6 @@ describe('form-spinbutton', () => {
7775
expect(wrapper.classes()).toContain('align-items-stretch')
7876
expect(wrapper.attributes('role')).toEqual('group')
7977
expect(wrapper.attributes('tabindex')).toEqual('-1')
80-
// We always have LTR to ensure the flex order stays ltr
81-
expect(wrapper.attributes('dir')).toEqual('ltr')
8278

8379
// Should have 3 child elements (btn, output, btn)
8480
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
@@ -136,8 +132,6 @@ describe('form-spinbutton', () => {
136132
expect(wrapper.classes()).toContain('align-items-stretch')
137133
expect(wrapper.attributes('role')).toEqual('group')
138134
expect(wrapper.attributes('tabindex')).toEqual('-1')
139-
// We always have LTR to ensure the flex order stays ltr
140-
expect(wrapper.attributes('dir')).toEqual('ltr')
141135

142136
// Should have 3 child elements (btn, output, btn)
143137
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
@@ -187,8 +181,6 @@ describe('form-spinbutton', () => {
187181
expect(wrapper.classes()).not.toContain('align-items-stretch')
188182
expect(wrapper.attributes('role')).toEqual('group')
189183
expect(wrapper.attributes('tabindex')).toEqual('-1')
190-
// We always have LTR to ensure the flex order stays ltr
191-
expect(wrapper.attributes('dir')).toEqual('ltr')
192184

193185
// Should have 3 child elements (btn, output, btn)
194186
expect(wrapper.findAll('.b-form-spinbutton > *').length).toBe(3)
@@ -774,8 +766,6 @@ describe('form-spinbutton', () => {
774766
expect(wrapper.classes()).not.toContain('focus')
775767
expect(wrapper.attributes('role')).toEqual('group')
776768
expect(wrapper.attributes('tabindex')).toEqual('-1')
777-
// We always have LTR to ensure the flex order stays ltr
778-
expect(wrapper.attributes('dir')).toEqual('ltr')
779769

780770
const $output = wrapper.find('output')
781771
expect($output.exists()).toBe(true)

0 commit comments

Comments
 (0)