Skip to content

Commit 99d271f

Browse files
committed
fix(BButton): BButton link props non-reactive
1 parent 311716c commit 99d271f

File tree

1 file changed

+25
-26
lines changed
  • packages/bootstrap-vue-3/src/components/BButton

1 file changed

+25
-26
lines changed

packages/bootstrap-vue-3/src/components/BButton/BButton.vue

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script lang="ts">
8-
import {resolveBooleanish} from '../../utils'
8+
import {isLink, resolveBooleanish} from '../../utils'
99
import {computed, defineComponent, PropType} from 'vue'
1010
import type {Booleanish, ButtonVariant, InputSize, LinkTarget} from '../../types'
1111
import {BLINK_PROPS} from '../BLink/BLink.vue'
@@ -34,12 +34,11 @@ export default defineComponent({
3434
const pressedBoolean = computed<boolean>(() => resolveBooleanish(props.pressed))
3535
const squaredBoolean = computed<boolean>(() => resolveBooleanish(props.squared))
3636
37-
// TODO none of these are computed values. Meaning they will not react if any of these are changed?
38-
const isToggle = pressedBoolean.value !== null
39-
const isButton = props.tag === 'button' && !props.href && !props.to
40-
const isLink = !!(props.href || props.to)
41-
const isBLink = !!props.to
42-
const nonStandardTag = props.href ? false : !isButton
37+
const isToggle = computed(() => pressedBoolean.value !== null)
38+
const isButton = computed(() => props.tag === 'button' && !props.href && !props.to)
39+
const link = computed(() => isLink(props))
40+
const isBLink = computed(() => !!props.to)
41+
const nonStandardTag = computed(() => (props.href ? false : !isButton.value))
4342
4443
const classes = computed(() => ({
4544
[`btn-${props.variant}`]: props.variant,
@@ -51,28 +50,28 @@ export default defineComponent({
5150
}))
5251
5352
const attrs = computed(() => ({
54-
'aria-disabled': nonStandardTag ? String(disabledBoolean.value) : null,
55-
'aria-pressed': isToggle ? String(pressedBoolean.value) : null,
56-
'autocomplete': isToggle ? 'off' : null,
57-
'disabled': isButton ? disabledBoolean.value : null,
53+
'aria-disabled': nonStandardTag.value ? String(disabledBoolean.value) : null,
54+
'aria-pressed': isToggle.value ? String(pressedBoolean.value) : null,
55+
'autocomplete': isToggle.value ? 'off' : null,
56+
'disabled': isButton.value ? disabledBoolean.value : null,
5857
'href': props.href,
59-
'rel': isLink ? props.rel : null,
60-
'role': nonStandardTag || isLink ? 'button' : null,
61-
'target': isLink ? props.target : null,
62-
'type': isButton ? props.type : null,
63-
'to': !isButton ? props.to : null,
64-
'append': isLink ? props.append : null,
65-
'activeClass': isBLink ? props.activeClass : null,
66-
'event': isBLink ? props.event : null,
67-
'exact': isBLink ? props.exact : null,
68-
'exactActiveClass': isBLink ? props.exactActiveClass : null,
69-
'replace': isBLink ? props.replace : null,
70-
'routerComponentName': isBLink ? props.routerComponentName : null,
71-
'routerTag': isBLink ? props.routerTag : null,
58+
'rel': link.value ? props.rel : null,
59+
'role': nonStandardTag.value || link.value ? 'button' : null,
60+
'target': link.value ? props.target : null,
61+
'type': isButton.value ? props.type : null,
62+
'to': !isButton.value ? props.to : null,
63+
'append': link.value ? props.append : null,
64+
'activeClass': isBLink.value ? props.activeClass : null,
65+
'event': isBLink.value ? props.event : null,
66+
'exact': isBLink.value ? props.exact : null,
67+
'exactActiveClass': isBLink.value ? props.exactActiveClass : null,
68+
'replace': isBLink.value ? props.replace : null,
69+
'routerComponentName': isBLink.value ? props.routerComponentName : null,
70+
'routerTag': isBLink.value ? props.routerTag : null,
7271
}))
7372
7473
const computedTag = computed<string>(() => {
75-
if (isBLink) return 'b-link'
74+
if (isBLink.value) return 'b-link'
7675
return props.href ? 'a' : props.tag
7776
})
7877
@@ -83,7 +82,7 @@ export default defineComponent({
8382
return
8483
}
8584
emit('click', e)
86-
if (isToggle) {
85+
if (isToggle.value) {
8786
emit('update:pressed', !pressedBoolean.value)
8887
}
8988
}

0 commit comments

Comments
 (0)