Manually setting focus on InputNumber component

UI Components for Vue
Post Reply
colinbes
Posts: 17
Joined: 26 May 2021, 23:50

02 Jan 2022, 20:58

I am needing to be able to manually set input focus on the InputNumber component.

I am using Vue3 Setup Script and seeing as InputNumber wraps html input tag in a span I have used pin_1.value.$el.children[0].focus where pin_1 is my ref to InputNumber

Code: Select all

<template>
	<InputNumber ref="pin_1" mode="decimal" />
</template>

<script setup lang="ts">
    	const pin_1 = ref()
    	const testFocus = () => {
    	 	const p1 = pin_1.value.$el.children[0]
  		p1.focus()
    	}
</script>

But this feels so messy and was wondering if there is a better way to do this?

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests