@dacfabre @martinbean
ok, although I've altered a few things. The name of ref to `listItem`, and am now trying to target listItem[5].
const listItem = ref([])
My v-for:
<li
v-for="(county, index) in project.data.counties"
v-show="showornot(index)"
class="project-counties-list"
ref="listItem"
:key="county.id"
>
{{ county.county_name }}, {{ index }}
</li>
In the button method for moving the focus, i've tried 1) testing for listItem[5], in which case it doesn't find it; or 2) moving the focus via listItem[5].value.focus(), which returns an error.
const showFullList = () => {
if (listItem) {
console.dir(listItem)
} else {
console.log('nope')
}
document.activeElement.blur()
showAllCounties.value = !showAllCounties.value
// const target = listItem[5]
// if (target) {
// target.value.focus()
// console.log('yes, ' +target)
// } else {
// console.log('no')
// }
listItem[5].value.focus()
}
But I can log both listItem (below) and listem[5] to the console:
RefImpl
dep
:
undefined
__v_isRef
:
true
__v_isShallow
:
false
_rawValue
:
(12) [li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list, li.project-counties-list]
_value
:
Proxy(Array) {0: li.project-counties-list, 1: li.project-counties-list, 2: li.project-counties-list, 3: li.project-counties-list, 4: li.project-counties-list, 5: li.project-counties-list, 6: li.project-counties-list, 7: li.project-counties-list, 8: li.project-counties-list, 9: li.project-counties-list, 10: li.project-counties-list, 11: li.project-counties-list}
value
:
(...)
[[Prototype]]
:
Object
From what I've read, there's something going on about the refs not rendering yet (or something like that), but it's not clear to me how to deal with it in a case like this.
showornot() just shows and hides list items based on index