AllenFang / react-bootstrap-table

A Bootstrap table built with React.js
https://allenfang.github.io/react-bootstrap-table/
MIT License
2.23k stars 782 forks source link

mode: radio with clickToSelectAndEditCell: true has wrong behaviour #1615

Open Paul6552 opened 7 years ago

Paul6552 commented 7 years ago

Hello, I think we have a wrong behaviour with clickToSelectAndEditCell: true and mode:radio

Situation 1: Any table with cellEdit={ cellEditTableData } selectRow={ selectRow } and this const values:

    const cellEditTableData = {
        mode: 'dbclick'
    };  
    const selectRow = {
        mode: 'radio',
        bgColor: function(row, isSelect) {
          if (isSelect) {
            return '#e6daac';
          }
          return null;
        }       
    };

Now we have a table with radio buttons. When we click on the radio button we can select a row. If we click on the same radio button of the row, which is right now selected, nothing happens. The row is still selected, we cannot unselect the row.

Situation 2: we have the same table again with celleditand with this changed const value for selectRow:

    const selectRowTableTaenze = {
        mode: 'radio',
                clickToSelectAndEditCell: true, //the difference to the first situation.
        bgColor: function(row, isSelect) {
          if (isSelect) {
            return '#e6daac';
          }
          return null;
        }       
    };

What happens now. We can click on the row -> The row is selected. We click again on the same row, which is right now selected -> suddenly I can deselect the row! This shouldn't happen if I have choosen mode: radio. I understand this behaviour when we have mode:checkbox, but on mode:radio it is not correct.

Thank you

AllenFang commented 7 years ago

@Paul6552 good point, I'll check it deeply. but actually, from the begin of this project, the single selection is not deselectable and no one to charge the deselect on radio button, So if you really want to able to deselect on radio, I can support it with additional props and also I'll fix this unconsistency issue.

Regards, Thanks