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

[EuiSelectable] Missing or partial documentation and types #4545

Open
dej611 opened this issue Feb 18, 2021 · 2 comments
Open

[EuiSelectable] Missing or partial documentation and types #4545

dej611 opened this issue Feb 18, 2021 · 2 comments

Comments

@dej611
Copy link
Contributor

dej611 commented Feb 18, 2021

I've recently implemented a component with EuiSelectable (within a popover - see elastic/kibana#91844) in Lens and want to share some feedback on the documentation. Hope this is helpful.

  • The onChange signature (EuiSelectableSearchProps) of the searchProps is slightly different compared to the one in EuiFieldSearch:
    • Intellisense is showing the different signature, but it's not super clear the options array content (you can guess it's only the matching array, but it would be useful to have it documented)
    • Because of this change it is not possible to control the searchTerm value from the outside. If passed it basically makes the component unusable for search
  • The onChange description for the EuiSelectable type is partial:

    Passes back the altered options array with selected options as

  • For some reason the "full" value for the height prop in the EuiSelectable seems to not work if the table is within a EuiPopover. I can only see the search field, but no list 🤔 .

As for testing, because of the internal AutoSizer used for the virtualization, the EuiSelectable list is not rendered at all - apparently on 0 dimensions is not even calling the children props, rather avoid any work.
So I came up with this trick in Jest to have the list rendered:

// Mock the AutoSizer inside EuiSelectable and return some dimensions > 0
jest.mock('react-virtualized-auto-sizer', () => {
  return function (props: {
    children: (dimensions: { width: number; height: number }) => React.ReactNode;
  }) {
    const { children, ...otherProps } = props;
    return <div {...otherProps}>{children({ width: 100, height: 100 })}</div>;
  };
});

Not super clean but in case somebody needs it in the future it's here.

@cchaos
Copy link
Contributor

cchaos commented Feb 19, 2021

For some reason the "full" value for the height prop in the EuiSelectable seems to not work if the table is within a EuiPopover. I can only see the search field, but no list 🤔 .

That's because EuiPopover's don't have an intrinsic height. The height is created by the content. Using full just sets the height to 100% meant to fill something like a flex-box with grow. (See Flyout example). In a popover, you will have to give the list an explicit height in pixels.

@dej611
Copy link
Contributor Author

dej611 commented Feb 19, 2021

Yes, that was the solution I ended up using 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants