Material-table: columns hidden:true hiddenByColumnsButton:true cause type error

Created on 28 Nov 2020  路  4Comments  路  Source: mbrn/material-table

Describe the bug
Setting columns hidden and hiddenByColumnsButton to "true" cause an "type undefined error" when unhiding the column.

Thrown Error:
Uncaught TypeError: Cannot read property 'match' of undefined

Where the Error was thrown:

var reducePercentsInCalc = function reducePercentsInCalc(calc, fullValue) {
  var captureGroups = calc.match(/(\d*)%/);

  if (captureGroups && captureGroups.length > 1) {
    var percentage = captureGroups[1];
    return calc.replace(/\d*%/, "".concat(fullValue * (percentage / 100), "px"));
  }

  return calc.replace(/\d*%/, "".concat(fullValue, "px"));
};

To Reproduce
Steps to reproduce the behavior:

  1. Create a column
columns = {
 { Title: 'some_title',field: 'some_field', hidden:true,hiddenByColumnsButton:true}
}
  1. Enable buttons to the table
    options = {columnsButton:true}
  2. After rendering the component select the columns button to show the hidden column.

Expected behavior
It will show the hidden column

Desktop (please complete the following information):

  • OS: Windows 10 Pro, 20H2
  • Browser: Chromium Edge, 87.0.664.47 (Official build) (64-bit)
  • Version 1.69.2

Additional context
What am I am trying to achieve is hide un necessary columns after render to de-clutter the table.
From searching I found some PR but is still pending. Is there any alternative workaround? Please help.

bug

Most helpful comment

Found a solution:

if calc is not truthy the function will return fullValue.

I will be creating a PR later.

All 4 comments

Found a solution:

if calc is not truthy the function will return fullValue.

I will be creating a PR later.

Same issue here, waiting for the PR from @nivranaitsirhc . Do you know exactly when this bug was introduced? Which version were you pointing at?

Update: I just checked and it stops working in version 1.65.0

This might not be fixed instantly.

I am not going to close this issue here, but we have implemented this fix over at @material-table We are a fork of material-table and we plan on pushing the changes up to material-table when we can. (only mbrn can update material-table.

Was this page helpful?
0 / 5 - 0 ratings