reactabular / searchtabular

Search utilities (MIT)
MIT License
5 stars 17 forks source link

Undefined value in highlighted column #7

Closed valerybugakov closed 7 years ago

valerybugakov commented 7 years ago

If I add column with empty values under search.highlighter then undefined will be shown in column explicitly.

undefined value is assigned to the row data in function returned by highlighter

    columns.forEach(function (column) {
        var property = column.property;
        var value = row[property];
        // Pick resolved value by convention
        var resolvedValue = row['_' + property] || value;

        ret[property] = value;

        // Retain possibly resolved value
        if (resolvedValue !== value) {
          ret['_' + property] = resolvedValue;
        }

        if (typeof property === 'undefined') {
          return;
        }

        // Stash highlighted value based on index
        // so it can be extracted later for highlighting
        ret._highlights[property] = matches({
          value: resolvedValue,
          query: query[property] || query.all
        });
      });

      // Capture original row data too
      return _extends({}, row, ret); // <--- row[property] === undefined assigned here

Is it done for some purpose? Thanks!

bebraw commented 7 years ago

Hi,

It could be missing some handling for that special case. Could you PR a fix? If I remember right, there should be pretty nice tests in place to help.

valerybugakov commented 7 years ago

Ok