Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select components may throw non-primitive key error #233

Closed
fairking opened this issue Mar 12, 2020 · 2 comments
Closed

Select components may throw non-primitive key error #233

fairking opened this issue Mar 12, 2020 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@fairking
Copy link

fairking commented Mar 12, 2020

Primevue v1.0.7

I got confused with the error message when my SelectButton clearly describes the key and that key is a string and it is definitely unique.

The implementation bellow:

<SelectButton id="actions" v-model="item.workflowState" data-key="id" :options="item.workflowStates" option-disabled="disabled">
    <template #option="slotProps">
        <div :title="slotProps.option.name">
            <span :class="slotProps.option.icon" style="margin:10px;"></span>
        </div>
    </template>
</SelectButton>

The error message is: [Vue warn]: Avoid using non-primitive value as key, use string/number value instead. Found in <SelectButton> at node_modules/primevue/components/selectbutton/SelectButton.vue

However if I add the label option-label="name" to the SelectButton the error dissapears.

I guess it is a bug, as the option-label is used as a key instead.

@fairking
Copy link
Author

fairking commented Mar 16, 2020

The source shows it is using a label as a key. I am not sure why:
image

@fairking
Copy link
Author

I guess it must use dataKey instead:

getOptionKey(option) {
            return this.dataKey ? ObjectUtils.resolveFieldData(option, this.dataKey) : option;
        },

@cagataycivici cagataycivici changed the title SelectButton Avoid using non-primitive value as key Select components may throw non-primitive key error Mar 17, 2020
@cagataycivici cagataycivici self-assigned this Mar 17, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Mar 17, 2020
@cagataycivici cagataycivici added this to the 1.1.0 milestone Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants