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

AutoComplete: selectedItemTemplate ts binding claims to expect JSX.Element in return, but at runtime a string is expected #1297

Closed
VsevolodGolovanov opened this issue Apr 6, 2020 · 1 comment
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@VsevolodGolovanov
Copy link

VsevolodGolovanov commented Apr 6, 2020

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)

https://codesandbox.io/s/primereact-test-rq9zd

https://codesandbox.io/s/primereact-test-umjwi (with #1296 workaround)

Current behavior
image

Actually returning JSX results in "[object Object]" in the input field when typing a query.
This is also due to #1296.

Even if you work around #1296 by doing

  selectedItemTemplate(value) {
    if (typeof value === "string")
      return value;
    else
      return <React.Fragment>{value.name}</React.Fragment>;
  }

You'd still get "[object Object]" when you select an item.

Expected behavior
The ts api should either specify a string as a return value.
Or, if #1296 is fixed, maybe JSX should actually be supported. Maybe the api should specify and support both JSX (as a template) and string (as a more dynamic alternative to label) as a valid return value.

Minimal reproduction of the problem with instructions
Type query into codesandbox.

Please tell us about your environment:

  • React version:
    16.13.1.

  • PrimeReact version:
    4.1.2.

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Tested in Firefox 74.

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

@VsevolodGolovanov VsevolodGolovanov changed the title AutoComplete: selectedItemTemplate ts binding claims to expect JSX.Element in return, but actually expects a string AutoComplete: selectedItemTemplate ts binding claims to expect JSX.Element in return, but in runtime a string is expected Apr 6, 2020
@VsevolodGolovanov VsevolodGolovanov changed the title AutoComplete: selectedItemTemplate ts binding claims to expect JSX.Element in return, but in runtime a string is expected AutoComplete: selectedItemTemplate ts binding claims to expect JSX.Element in return, but at runtime a string is expected Apr 6, 2020
@cagataycivici cagataycivici self-assigned this Apr 16, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a defect related to a specific component. label Apr 16, 2020
@cagataycivici cagataycivici added this to the 4.2.0 milestone Apr 16, 2020
@cagataycivici
Copy link
Member

Type should be a string, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

2 participants