Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

I have a list of buttons, and I can't click tab and roll through them. It only focuses…

  1. User

    I have a list of buttons, and I can't click tab and roll through them. It only focuses the currently selected one. Code: <q-tab style="width: 100%" :disable="!loaded" :name="instance.label" v-for="(instance, index) in instances" @click="switchTab(index)" :id="instance.label + '-button'">{{ instance.label }} <q-tab v-if="isSuper && instances.length < 3" icon="add" :disable="!loaded" @click="openAdd()"> What do I do to make each button in this loop selectable wiht tab?

  2. Assistant

    To make each button in the loop selectable with tab, you need to add the tabindex attribute to each button element and set it to a unique value. Here's an example of how you can modify your code:

    <q-tabs v-model="activeInstance" dense style="background-color: #efefef;" class="tabs"
        active-class="bg-negative text-white" indicator-color="negative" align="justify">
        <q-tab v-for="(instance, index) in instances" :key="index" style="width: 100%"
            :disable="!loaded" :name="instance.label"
            v-bind:id="instance.label + '-button'"
            tabindex="0" <!-- Add tabindex attribute and set it to a unique value -->
            @click="switchTab(index)">{{ instance.label }}</q-tab>
        <!-- For adding dev test or prod-->
        <q-tab v-if="isSuper && instances.length < 3" icon="add" :disable="!loaded"
            @click="openAdd()" tabindex="0"></q-tab> <!-- Add tabindex attribute and set it to a unique value -->
    </q-tabs>
    

    By setting the tabindex attribute to a value greater than zero, you make each button focusable with the tab key. The value of tabindex determines the order in which the elements are focused when you press the tab key.