Skip to content

Commit 3c3970d

Browse files
committed
Update ArrowBtn.vue
add type definitions to defineEmits. create helper function to return elRef (prevents eslint to chenge it to elRef.value)
1 parent 4f6ed35 commit 3c3970d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/VueDatePicker/components/Common/ArrowBtn.vue

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
tabindex="0"
88
:aria-label="ariaLabel"
99
:aria-disabled="disabled || undefined"
10-
@click="$emit('activate')"
11-
@keydown="checkKeyDown($event, () => $emit('activate'), true)"
10+
@click="emit('activate')"
11+
@keydown="checkKeyDown($event, () => emit('activate'), true)"
1212
>
1313
<span class="dp__inner_nav" :class="{ dp__inner_nav_disabled: disabled }">
1414
<slot />
@@ -17,7 +17,7 @@
1717
</template>
1818

1919
<script lang="ts" setup>
20-
import { onMounted, ref } from 'vue';
20+
import { onMounted, ref, type Ref } from 'vue';
2121
import { checkKeyDown } from '@/utils/util';
2222
2323
defineOptions({
@@ -26,7 +26,10 @@
2626
},
2727
});
2828
29-
const emit = defineEmits(['activate', 'set-ref']);
29+
const emit = defineEmits<{
30+
'activate': []
31+
'set-ref': [i: Ref<HTMLElement | null>]
32+
}>();
3033
3134
defineProps<{
3235
ariaLabel?: string;
@@ -36,5 +39,9 @@
3639
3740
const elRef = ref<HTMLElement | null>(null);
3841
39-
onMounted(() => emit('set-ref', elRef.value));
42+
function getRefElement(): Ref<HTMLElement | null> {
43+
return elRef
44+
}
45+
46+
onMounted(() => emit('set-ref', getRefElement()));
4047
</script>

0 commit comments

Comments
 (0)