# EUI BasicTable selection updates not reflecting

**URL:** https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310
**Category:** Kibana
**Created:** [March 26, 2020, 11:37pm UTC](https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310 "2020-03-26T23:37:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tiburon\_security](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiburon_security/32/45613_2.png) [@tiburon\_security](https://discuss.elastic.co/u/tiburon_security)
#### Post date: [March 26, 2020, 11:37pm UTC](https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310/1 "2020-03-26T23:37:55Z")

</div>

Hi all, I'm using an EUI BasicTable with the selection feature for performing actions against rows of data. However, when I programatically update the tables selection (for example in response to an action against a row) the table UI selection isn't updated. This is a bit difficult to explain, but here's a code snippet:

> **[Working EUI - CodeSandbox](https://codesandbox.io/s/working-eui-ip2rk)**
>
> This allows you to use and extend EUI on Code Sandbox.

In this example, I've coded the table such that when you select a row and click the acknowledge button, the selection state is zero'd out, with the intention that the checkbox selection is removed in the table UI. However, while the state is updated, the table UI isn't reflected to render the change. Am I doing something wrong here?

Thanks!

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [March 27, 2020, 1:09pm UTC](https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310/2 "2020-03-27T13:09:50Z")

</div>

In your code the `selectedItems` state is just bookkeeping what's happening within the table, but it's not passed back into the table.

This means when resetting the state managed in your component:

```auto
this.setState({ selectedItems: [] }

```

The table won't notice at all - it's just affecting the bookkeeping state of your own component.

The state which entries are selected and which are not are completely managed by the table component and are not changeable from the outside.

This is definitely a reasonable feature and it's worth opening a feature request for it here: [https://github.com/elastic/eui/issues/new](https://github.com/elastic/eui/issues/new)

A workaround for this I can think of is to pass a `key` prop to the `EuiBasicTable` component and change that key prop when resetting the selection status.

A different `key` signals to react that this is another component in the tree and it will set up a fresh instance which will effectively reset the selection state.

---

<div class="post-metadata">

### Author: ![tiburon\_security](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiburon_security/32/45613_2.png) [@tiburon\_security](https://discuss.elastic.co/u/tiburon_security)
#### Post date: [March 27, 2020, 6:30pm UTC](https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310/3 "2020-03-27T18:30:19Z")

</div>

This did the trick, thank you! I'll submit a feature request soon.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 24, 2020, 6:30pm UTC](https://discuss.elastic.co/t/eui-basictable-selection-updates-not-reflecting/225310/4 "2020-04-24T18:30:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
