enso-ui / select

Select
MIT License
2 stars 3 forks source link

cursive writing/font not supported on dropdown #2

Closed YacoubBelaoura closed 5 years ago

YacoubBelaoura commented 5 years ago

This is a bug ?.

Prerequisites

Description

the vue-select dropdown dont suport cursive writing fonts and languages like 'arabic' example screenshots deco01 decomposed

Steps to Reproduce

  1. visit Edit Permission and change language to arabic "use cursive writing" and click on type select dropdown menu, you will notice it separate characters.

Expected behavior

for cursive fonts it should keep it like it is normalLang

Actual behavior

decomposed

reason ?

the <b> tag around RegExp text

        highlight(label) {
            return label.replace(
                new RegExp(`(${this.query})`, 'gi'), '<b>$1</b>',
            );
        },
aocneanu commented 5 years ago

If we remove the <b> how do we highlight the matched string from an option?

YacoubBelaoura commented 5 years ago

my solution is to use this Zero-width joiner add &#x200d; after <b> tag

        highlight(label) {
            return label.replace(
                new RegExp(`(${this.query})`, 'gi'), '&#x200d;<b>$1</b>',
            );

here is the output. output

aocneanu commented 5 years ago

you mean before the <b> tag?

So just to be clear, doing this fixes the reported problem?

YacoubBelaoura commented 5 years ago

the problem is that this function will inject empty <b> tags in select options.

        highlight(label) {
            return label.replace(
                new RegExp(`(${this.query})`, 'gi'), '<b>$1</b>',
            );
        },

like here:

<span>‍<b></b>ق‍<b></b>ر‍<b></b>ا‍<b></b>ء‍<b></b>ة‍<b></b></span>

so the fix is only to inject <b> tag when there is a query. so here is the working fix:

        highlight(label) {
            if (this.query.length > 0) {
                return label.replace(
                    new RegExp(`(${this.query})`, 'gi'), '<b>$1</b>',
                );
            } else {
                return label;
            }
        },

i will make a PR if you approve.

aocneanu commented 5 years ago

@YacoubBelaoura, I forgot about this, do a PR.

Thanks.

PS use a ternary instead of if else.