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

Bug: Invalid prop: type check failed for prop "modelValue" #5090

Closed
5 tasks done
han2-n opened this issue Dec 10, 2024 · 6 comments · Fixed by #5127
Closed
5 tasks done

Bug: Invalid prop: type check failed for prop "modelValue" #5090

han2-n opened this issue Dec 10, 2024 · 6 comments · Fixed by #5127
Labels
bug Something isn't working

Comments

@han2-n
Copy link

han2-n commented Dec 10, 2024

Version

Vben Admin V5

Describe the bug?

[ElementPlus ] When I use the Select component, and the binding value of the Select is an object, enabling the filterable property causes the input to always reflect the bound value as the search box value (string value).

Reproduction

1: Code impl
image
2: Log result after search on select
image

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
    Memory: 602.43 MB / 15.85 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\scoop\apps\yarn\current\bin\yarn.CMD
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.13.2 - ~\AppData\Local\pnpm\pnpm.EXE
    bun: 1.1.18 - ~\AppData\Roaming\npm\bun.CMD
  Browsers:
    Internet Explorer: 11.0.19041.4355

Relevant log output

No response

Validations

@mynetfan
Copy link
Collaborator

Your version?
ApiSelect need to set component prop value

@han2-n
Copy link
Author

han2-n commented Dec 10, 2024

Your version? ApiSelect need to set component prop value

version: lastest
ApiSelect is component i define wrapper VbenApiSelect

image

@mynetfan
Copy link
Collaborator

More information is needed to infer the problem

@han2-n
Copy link
Author

han2-n commented Dec 10, 2024

I found warn issue: because i defineModel must return object
But i think form data binding is still an issue.

U can see flow and code below

  {
      // 组件需要在 #/adapter.ts内注册,并加上类型
      component: 'ApiSelect',
      // 对应组件的参数
      componentProps: {
        // 菜单接口转options格式
        afterFetch: (data: { name: string; path: string }[]) => {
          return data.map((item: any) => ({
            label: item.name,
            value: item,  // change here
          }));
        },
        filterable: true, // change here
        valueKey: 'path', // change here
        // 菜单接口
        api: getAllMenusApi,
      },
      // 字段名
      fieldName: 'api',
      // 界面显示的label
      label: 'ApiSelect',
  }
  • Step 2: Select record then submit data, the data will look like the image below
    image

  • Step 3: Enter input some text to search then click outside or click submit form
    image

  • So I think the main reason is that it automatically binds the search input data as the value for the form field.

Expect result: must like Element plust Option filtering

  • When clicking outside, the search text will automatically clear. And the search text data not be binding for the form field.

@han2-n
Copy link
Author

han2-n commented Dec 10, 2024

More information is needed to infer the problem

This issue occurs in the Select component. I have found that the onInput event in VbenForm seems to be the cause.
So i hot fix like:

 componentProps: {
      onInput: undefined,
 },

However, it is not sufficient when I am integrating it with VbenApiSelect, as the issue happens again.

@han2-n
Copy link
Author

han2-n commented Dec 13, 2024

@mynetfan when I am integrating it with VbenApiSelect, as the issue happens again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants