Skip to content

Not passing options object to Advanced Select option results in undefined data attribute #760

@robinsonjohn

Description

@robinsonjohn

Summary

https://preline.co/docs/components/advanced-select.html

Steps to Reproduce

const selectEl = document.getElementById('advanced-select');
const hs = new HSSelect(selectEl);

hs.addOption([
    {
        title: 'John',
        val: '1'
    },
    {
        title: 'Steve',
        val: '2'
    },
    {
        title: 'Bob',
        val: '3'
    },
]);

When viewing the source, the options look like:

<option value="1" data-hs-select-option="undefined">John</option>
<option value="2" data-hs-select-option="undefined">Steve</option>
<option value="3" data-hs-select-option="undefined">Bob</option>

Demo Link

https://preline.co/docs/components/advanced-select.html

Expected Behavior

If no options object is passed, omit setting the data-hs-select-option attribute altogether.

Actual Behavior

The data-hs-select-option attribute is set on each option whether it exists or not.

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions