Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 700b77d

Browse files
authored
Merge pull request bootstrap-vue-next#1467 from VividLemon/main
fix(BForm): expose the form so you can programatically submit fixes b…
2 parents 7865d97 + 4269fa5 commit 700b77d

File tree

11 files changed

+33
-11
lines changed

11 files changed

+33
-11
lines changed

packages/bootstrap-vue-next/src/components/BAlert/BAlert.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ watch(isHovering, (newValue) => {
159159
160160
onBeforeUnmount(stop)
161161
162-
defineExpose({pause, resume, restart, stop})
162+
defineExpose({
163+
pause,
164+
resume,
165+
restart,
166+
stop,
167+
})
163168
</script>
164169

165170
<style lang="scss" scoped>

packages/bootstrap-vue-next/src/components/BCarousel/BCarousel.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@ watch(isHovering, (newValue) => {
315315
onMouseLeave()
316316
})
317317
318-
defineExpose({pause, resume, prev, next})
318+
defineExpose({
319+
pause,
320+
resume,
321+
prev,
322+
next,
323+
})
319324
320325
provide(carouselInjectionKey, {
321326
background: toRef(() => props.background),

packages/bootstrap-vue-next/src/components/BForm/BForm.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<form
33
:id="id"
4+
ref="element"
45
:novalidate="novalidateBoolean"
56
:class="computedClasses"
67
@submit.prevent="submitted"
@@ -12,7 +13,7 @@
1213
<script setup lang="ts">
1314
import type {BFormProps} from '../../types'
1415
import {useBooleanish} from '../../composables'
15-
import {computed} from 'vue'
16+
import {computed, ref} from 'vue'
1617
1718
const props = withDefaults(defineProps<BFormProps>(), {
1819
floating: false,
@@ -25,6 +26,8 @@ const emit = defineEmits<{
2526
submit: [value: Event]
2627
}>()
2728
29+
const element = ref<HTMLFormElement | null>(null)
30+
2831
const floatingBoolean = useBooleanish(() => props.floating)
2932
const novalidateBoolean = useBooleanish(() => props.novalidate)
3033
const validatedBoolean = useBooleanish(() => props.validated)
@@ -42,4 +45,8 @@ const computedClasses = computed(() => ({
4245
const submitted = (e: Event) => {
4346
emit('submit', e)
4447
}
48+
49+
defineExpose({
50+
element,
51+
})
4552
</script>

packages/bootstrap-vue-next/src/components/BFormCheckbox/BFormCheckbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ const inputClasses = getInputClasses(classesObject)
256256
const labelClasses = getLabelClasses(classesObject)
257257
258258
defineExpose({
259+
element: input,
259260
focus: () => {
260261
focused.value = true
261262
},
262263
blur: () => {
263264
focused.value = false
264265
},
265-
input,
266266
})
267267
</script>

packages/bootstrap-vue-next/src/components/BFormFile/BFormFile.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ watch(modelValue, (newValue) => {
154154
})
155155
156156
defineExpose({
157+
element: input,
157158
focus: () => {
158159
focused.value = true
159160
},
160161
blur: () => {
161162
focused.value = false
162163
},
163164
reset,
164-
input,
165165
})
166166
</script>

packages/bootstrap-vue-next/src/components/BFormInput/BFormInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ const computedClasses = computed(() => {
112112
})
113113
114114
defineExpose({
115+
element: input,
115116
focus,
116117
blur,
117-
input,
118118
})
119119
120120
// const highlight = () => {

packages/bootstrap-vue-next/src/components/BFormRadio/BFormRadio.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ const inputClasses = getInputClasses(classesObject)
168168
const labelClasses = getLabelClasses(classesObject)
169169
170170
defineExpose({
171+
element: input,
171172
focus: () => {
172173
focused.value = true
173174
},
174175
blur: () => {
175176
focused.value = false
176177
},
177-
input,
178178
})
179179
</script>

packages/bootstrap-vue-next/src/components/BFormSelect/BFormSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ const localValue = computed({
159159
})
160160
161161
defineExpose({
162+
element: input,
162163
focus: () => {
163164
focused.value = true
164165
},
165166
blur: () => {
166167
focused.value = false
167168
},
168-
input,
169169
})
170170
</script>

packages/bootstrap-vue-next/src/components/BFormTags/BFormTags.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ const removeTag = (tag?: string): void => {
455455
456456
// TODO these focus/blur events aren't quite in line with use useFormInput implementation. Perhaps we should bring them together?
457457
defineExpose({
458+
element: input,
458459
focus: () => {
459460
focused.value = true
460461
},
461462
blur: () => {
462463
focused.value = false
463464
},
464-
input,
465465
})
466466
</script>

packages/bootstrap-vue-next/src/components/BFormTextarea/BFormTextarea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ const computedStyles = computed<CSSProperties>(() => ({
101101
}))
102102
103103
defineExpose({
104+
element: input,
104105
focus,
105106
blur,
106-
input,
107107
})
108108
</script>

packages/bootstrap-vue-next/src/components/BToast/BToast.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,10 @@ watch(isHovering, (newValue) => {
204204
205205
onBeforeUnmount(stop)
206206
207-
defineExpose({pause, resume, restart, stop})
207+
defineExpose({
208+
pause,
209+
resume,
210+
restart,
211+
stop,
212+
})
208213
</script>

0 commit comments

Comments
 (0)