carbon-addons-iot-react icon indicating copy to clipboard operation
carbon-addons-iot-react copied to clipboard

[Table] callback issues when single select with Radio buttons props are set

Open davidicus opened this issue 3 years ago • 1 comments

What package is this for?

  • [x] React
  • [ ] Angular

Describe the bug

There are two defects surrounding the single select behavior with radio buttons.

  1. On line 252 of TableBodyRow.jsx we are calling onRowSelected inside an onChange event for the TableCell. We are also calling the onRowSelected when the RadioButto element is clicked on line 265. We should only be calling this once. You can see this in our storybook here. Make sure options.hasRowSelection is set to 'single' and the options.useRadioButtonSingleSelect options is clicked in the 'Selections and actions' knob tab. Then open the actions panel and click on the radio button. You will see the callback fired twice.
  2. With the same story and knobs active try clicking on the row in an area outside of the radio button cell with the actions tab open. You will see that an onRowSelected and an onRowClicked callback are fired. Notice that the radio button does not show a selected state. This most likely stems to when we added the radio buttons for single selection. Previously, a user could click anywhere and it would select the row. @JordanWSmith15 @dianatran18 can you chime in with whether we should continue to allow the clicking on a row to fire the onRowSelected and update the radio button accordingly or disallow row clicks to fire the onRowSelected when we are using radio buttons?

@JordanWSmith15 This is related to the defect being worked by Tom for Graphite.

To Reproduce

Steps to reproduce the behavior:

  1. Go to this story
  2. Got to the 'Selections and actions' knob tab in the knob pannel.
  3. Make sure options.hasRowSelection is set to 'single' and the options.useRadioButtonSingleSelect options is clicked
  4. Open the actions panel
  5. Click on the radio button in the table
  6. See the action firing twice.
  7. Click anywhere in the row and see the onRowSelected callback being fired.

We will want to make sure that our behavior for single select without the radio buttons and the multi-select functionality is preserved.

davidicus avatar Oct 24 '22 19:10 davidicus

Codecov Report

Base: 63.92% // Head: 63.92% // No change to project coverage :thumbsup:

Coverage data is based on head (becf8bb) compared to base (4bea68e). Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2075   +/-   ##
=======================================
  Coverage   63.92%   63.92%           
=======================================
  Files          73       73           
  Lines        6398     6398           
=======================================
  Hits         4090     4090           
  Misses       2308     2308           
Flag Coverage Δ
pytest 63.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

dianasanborn avatar Oct 24 '22 19:10 dianasanborn