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

Cannot use IntelliSense for Select component #290

Open
abdullahtellioglu opened this issue Jan 13, 2025 · 8 comments · May be fixed by #291
Open

Cannot use IntelliSense for Select component #290

abdullahtellioglu opened this issue Jan 13, 2025 · 8 comments · May be fixed by #291
Labels
bug Something isn't working

Comments

@abdullahtellioglu
Copy link

Describe the bug

Select component type seems like ForwardRefExoticComponent<unknown> where properties are not accessible through IntelliSense. IntelliSense works for other components such as NumberField, TextField but does not for some.

TextField example:
Screenshot 2025-01-13 at 13 23 45

Select example:
Screenshot 2025-01-13 at 13 24 02

Expected-behavior

Props should be defined for Select component.

Reproduction

Any react component with Select would work.

function AddressForm(props: { street: string; city: string; zip: string }) {
  const { street, city, zip } = props;
  const items = [
    {
      label: 'Most recent first',
      value: 'recent',
    },
    {
      label: 'Rating: high to low',
      value: 'rating-desc',
    },
    {
      label: 'Rating: low to high',
      value: 'rating-asc',
    },
    {
      label: 'Price: high to low',
      value: 'price-desc',
    },
    {
      label: 'Price: low to high',
      value: 'price-asc',
    },
  ];
  return (
    <>
      <TextField label={street}></TextField>
      <TextField label={city}></TextField>
      <NumberField label={zip}></NumberField>
      <Select items={items}></Select>
    </>
  );
}

System Info

Hilla: 24.7.0.alpha5
Flow: 24.7.0.alpha4
Vaadin: 24.7.0.alpha3
Copilot: 24.7-SNAPSHOT
Frontend Hotswap: Enabled, using Vite
OS: aarch64 Mac OS X 14.7.1
Java: JetBrains s.r.o. 21.0.5
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Java Hotswap: Java Hotswap is enabled
IDE Plugin: 1.0-SNAPSHOT IntelliJ

@abdullahtellioglu abdullahtellioglu added bug Something isn't working hilla labels Jan 13, 2025
@platosha platosha transferred this issue from vaadin/hilla Jan 14, 2025
@platosha platosha removed the hilla label Jan 14, 2025
@web-padawan
Copy link
Member

web-padawan commented Jan 14, 2025

We use forwardRef for quite a few components like Dialog, MenuBar, Popover, TabSheet, TimePicker etc.
Could you please clarify if this issue applies to all of them or is it somehow specific only to Select component?

UPD: this was reported previously in #165 and was considered as fixed by #167

@abdullahtellioglu
Copy link
Author

This issue applies to all. It is quite hard to use components when you do not have the type. You are quite forced to use documentation for such components.

@abdullahtellioglu
Copy link
Author

Can you see the properties of such a component? IntelliSense gives ForwardRefExoticComponent<unknown> for the Select component in IntelliJ to me

@web-padawan
Copy link
Member

I can confirm the issue, it also shows ForwardRefExoticComponent<unknown> and doesn't show suggestions.

Note, when in react-components project the issue manifests when importing like this:

import { Select } from '@vaadin/react-components';
Image

However, when you use local relative import, then it looks as expected:

import { Select } from '../../packages/react-components/src/Select.js';
Image

@web-padawan
Copy link
Member

Looks like we can improve this by specifying return types for forwardRef() calls as e.g. ComboBox works fine.

const ForwardedSelect = forwardRef(Select) as (
  props: SelectProps & RefAttributes<SelectElement>,
) => ReactElement | null;

I'll test if this works for all components that use the same approach and then create a PR.

@abdullahtellioglu
Copy link
Author

Thanks, @web-padawan 🙇 It would increase the usability of components significantly, in my opinion.

@web-padawan
Copy link
Member

@abdullahtellioglu What version of IntelliJ do you have?

I was able to reproduce the issue was there with IntelliJ 2023.3.8, however after upgrading to 2024.3.1.1 the problem is gone:

Image

@abdullahtellioglu
Copy link
Author

I have 2024.1 version. Let me upgrade it and check it 👍

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

Successfully merging a pull request may close this issue.

3 participants