Vue-multiselect: Placeholder styling

Created on 15 Sep 2018  路  12Comments  路  Source: shentao/vue-multiselect

Steps to reproduce

When value is empty/null, the placeholder is shown

Expected behaviour

The placeholder style should be different from the style of a value

Actual behaviour

The span containing the placeholder has no additional CSS class, hence we cannot style it differently.

Most helpful comment

Working code (but very verbose when you have lots of selects):

                    <vue-multiselect
                            track-by="id"
                            label="label"
                            v-model="newItem.role"
                            :options="legalRepresentativeRoles">
                        <template slot="placeholder">
                            <span class="multiselect__placeholder">R么le du repr茅sentant l茅gal dans la structure</span>
                        </template>
                    </vue-multiselect>

All 12 comments

Vue code:

<vue-multiselect
                            track-by="id"
                            label="label"
                            v-model="newItem.role"
                            placeholder="R么le du repr茅sentant l茅gal dans la structure"
                            :options="legalRepresentativeRoles"></vue-multiselect>

Rendered in browser:

//...
<span><span class="multiselect__single">
            R么le du repr茅sentant l茅gal dans la structure
          </span></span>
</div> 
//...

Working code (but very verbose when you have lots of selects):

                    <vue-multiselect
                            track-by="id"
                            label="label"
                            v-model="newItem.role"
                            :options="legalRepresentativeRoles">
                        <template slot="placeholder">
                            <span class="multiselect__placeholder">R么le du repr茅sentant l茅gal dans la structure</span>
                        </template>
                    </vue-multiselect>

Same issue. Why is this closed? Why are their remnants of a class existing "multiselect__placeholder" and it not being applied to an actual placeholder.

I did not get it either :/

@williamabbott please look into the source code:

        <span
          v-if="isPlaceholderVisible"
          class="multiselect__placeholder"
          @mousedown.prevent="toggle">
          <slot name="placeholder">
              {{ placeholder }}
          </slot>
        </span>

As you can see, the .multiselect__placeholder class is still there and applied. However, when the component is searchable we鈥檙e using the native placeholder of an input. I imagine the latter could be working different (ditching the native placeholder all together). A PR is welcome in this case.

@shentao when I focus the multiselect, I can see it reverts to displaying the native placeholder (this is styled, as I want, as per other inputs) but in an unfocused state, it is using:

<span class="multiselect__single"> My placeholder </span>

Please provide a reproduction fiddle.

I will accept a PR that improves this :)

I don't know about anyone else in this thread but my issue was resolved by bumping version 2.1.0 -> 2.1.3

Thanks, it' helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanheimann picture stefanheimann  路  4Comments

zachleigh picture zachleigh  路  3Comments

shsmad picture shsmad  路  3Comments

yaakovp picture yaakovp  路  3Comments

hskrishna29 picture hskrishna29  路  3Comments