Column width lost if width is defined
Bug occurs in react-data-grid-multiline-header v1.0.0.
If you specify a width for a column, when you call the Helper function in ReactDataGridMultilineHeader, the column width you have set can get lost. Specifically, this will happen when the text width will fit within the column width without being forced to two lines.
The ReactDataGridMultilineHeader, _setColumnWidth() will perform a check for textWidth <= maxTextWidth. If this is true (meaning the text will fit in the column width provided), the rest of the code will then set the column width to config.maxWidth, thus losing what was originally set.
The fix I used to get this to work is, within this block, check to see if column.width is not set. If it isn't set, then the code will continue with what was originally written in v1.0.0. Otherwise, the column width will not be set and the original width will be retained. If the column width was never set by the caller, then the config.minWidth will be established and all is fine.
My version of the if check up to the else (starting with line 78): if (textWidth <= maxTextWidth) { // If the column width was defined, then keep that. Otherwise, the width will be set to either the minWidth // or the space the text will take up, whichever is greater. // Original released code (v1.0.0) did not keep the column width that was set. if (!column.width) { column.width = Math.max(_this._config.minWidth, textWidth + padding); } } else {
Original code: if (textWidth <= maxTextWidth) { column.width = Math.max(_this._config.minWidth, textWidth + padding); } else {