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

a-select search doesn't support Chinese labels #4870

Closed
1 task done
immzz opened this issue Nov 11, 2021 · 5 comments
Closed
1 task done

a-select search doesn't support Chinese labels #4870

immzz opened this issue Nov 11, 2021 · 5 comments
Labels

Comments

@immzz
Copy link

immzz commented Nov 11, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.0.0-alpha.9

Environment

MacOS, Chrome 95.0, Vue 3

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • add a Chinese label in options when rendering a-select, for example:
const options = ref<SelectProps['options']>([
      { value: 'jack', label: '这是一段中文' },
      { value: 'lucy', label: 'Lucy' },
      { value: 'tom', label: 'Tom' },
    ]);
  • enable search by adding show-search attribute to a-select
  • type any character of the Chinese label
  • a-select shows "No Data"

What is expected?

a-select should show the options that contains the input as a substring.

What is actually happening?

a-select shows "No Data"

@immzz
Copy link
Author

immzz commented Nov 11, 2021

This is also reproducible in other versions of antdv, for example in 2.2.8:
https://codesandbox.io/embed/dai-sou-suo-kuang-ant-design-vue-next-forked-hov91?fontsize=14&hidenavigation=1&theme=dark

@776A0A
Copy link

776A0A commented Nov 11, 2021

This is also reproducible in other versions of antdv, for example in 2.2.8: https://codesandbox.io/embed/dai-sou-suo-kuang-ant-design-vue-next-forked-hov91?fontsize=14&hidenavigation=1&theme=dark

you can use filterOption. According to your code, you did not pass filterOption to a-select.
And you need to change the code to

const filterOption = (input: string, option: any) => {
      return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 || String(option.label).includes(input);
    };

@immzz
Copy link
Author

immzz commented Nov 11, 2021

I'm assuming this should be supported by default since it's a pretty basic use case. Do we need to update the default filter option?

@tangjinzhou
Copy link
Member

set filterOption

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants