buildo / react-components

Collection of general React components used in buildo projects.
http://react-components.buildo.io/
MIT License
157 stars 21 forks source link

dropdown - selectAll option handling #1369

Closed Cardu closed 5 years ago

Cardu commented 5 years ago

Closes [#2520959](https://buildo.kaiten.io/space/[object Object]/card/2520959)

⚠️ The line above was added during the automatic migration of all github project issues to Kaiten. The old GH issue link is kept here for reference (it is now deprecated, continue follow the original issue on Kaiten).

Closes #947

⚠️ Not ready to merge, just a prototype to show the idea

Cardu commented 5 years ago

Alternative implementation that I was talking about on slack: https://buildo.slack.com/archives/C289TFRAQ/p1568460163000100?thread_ts=1568380065.007700&cid=C289TFRAQ

Cardu commented 5 years ago

Tested customizing the example dropdown like this:

initialState = {};

const onChange = value => value === 'all' ? setState({ value: {value: 'all', label: "tutti quanti"} }) : setState({ value });

const options = [
  { value: "apple", label: "Apple" },
  { value: "avocado", label: "Avocado" },
  { value: "orange", label: "Orange" },
  { value: "lemon", label: "Lemon" },
  { value: "mandarin", label: "Mandarin" }
];

console.debug(state);

<Dropdown
    showSelectAll
    selectAllLabel='selezionami tutto'
  type="single"
  value={state.value}
  onChange={onChange}
  placeholder="Select some fruit"
  options={options}
/>;
fes300 commented 5 years ago

@Cardu can we close this?

Cardu commented 5 years ago

@fes300 nope! ⚠️ this branch was just a demonstration and it should be deleted, I think @veej is working on the "good" version of this

Cardu commented 5 years ago

If you meant close without merging and destroy the branch, then definitively yes