acl-services / acl-services/paprika

<ListBox /> Better api for a fully controlled multiselect listbox with filter and footer

Abierto
#509 0 comentarios 1 reacción 0 asignados Ver en GitHub
High Priority ↑
Lenguaje dominante
JavaScript
Estrellas
54
Forks
10
Merge medio
1 d 12 h
PR fusionados (30 d)
6

Descripción

# Feature request

## Is your feature request related to a problem?

In projects, we have lots of common case like a multiselect filter using paginated API and searching API to render the listbox options, and most of them are using ``.
Example like here:
![image](https://user-images.githubusercontent.com/38733362/80763893-6044db00-8af4-11ea-9982-2af782148f9a.png)

When we have a listbox footer and the multiselect become explicit, if users click outside to close the popover, we should revert the listbox state to the previous state, like a Cancel action if users click the `Cancel` button in ``. When we dispatch the `cancel` action in listbox component, we should revert the state of `selectedOptions`.

Sometimes we have to use a fully controlled listbox, because we need to refresh the list of options each time when searching or fetching more data. Using a fully controlled listbox with footer means I have to sync the `selectedOptions`, between my application and the listbox component. Currently there's no way to sync the internal state of listbox from outside, I can only render the `ListBox.Option` component by a controlled way like ``, but that doesn't mean I updated the internal state of listbox. This is causing some weird bugs, like sometimes listbox label cannot find the selected item, because the `options` are updated, but `selectedIds` didn't.

## Describe the solution you'd like

First I wish in my app I can remove and add my ``, `` without any issues

Then, I wish it would be easier to use a multiselect listbox like this:

```jsx

'call my API and refresh the option list'}}/>
{
myOptions.map(option => )
}
'I can revert my option list'}
/>

```
If I can get the previous state from listbox component, I don't need to cache it in my app, it will save lots of effort in my application side.

## Describe alternatives you've considered

## Additional context

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.