glideapps / glideapps/glide-data-grid

themeOverrides with `undefined` values result in Error during render.

Open
#1,180 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Hello,

First of all thanks for developing this project. We use this in production to implement a minimal spreadsheet-like preview and it works great!

We recently bumped the dependency of `@glideapps/glide-data-grid` and `@glideapps/glide-data-grid-source` from `5.3.2` to `6.0.4-alpha24` and got this "crash":

```js
color-parser.js:17 Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')
at parseToRgba (color-parser.js:17:1)
at blend (color-parser.js:67:1)
at mergeAndRealizeTheme (styles.js:109:1)
at data-grid-render.header.js:33:1
at walkColumns (data-grid-render.walk.js:43:1)
at drawGridHeaders (data-grid-render.header.js:22:1)
at drawHeaderTexture (data-grid-render.js:147:1)
at drawGrid (data-grid-render.js:231:1)
at data-grid.js:393:1
at data-grid.js:451:1
```

Which looks to end up at this line:

https://github.com/glideapps/glide-data-grid/blob/0875d78cc41535a39f8b417ff88ce1ebe129c363/packages/core/src/internal/data-grid/color-parser.ts#L23

Our offending code/repro defined a themeOverride like this on the `GridColumn` type:

```js
themeOverride: {
bgCell: visualizeHidden ? 'lightgrey' : undefined,
bgHeader: visualizeHidden ? 'lightgrey' : undefined,
}
```

It's of course quite easy to get around this issue for us by filtering out undefined properties from the `themeOverride`. But I wanted to give you the chance to fix this if you consider it a bug in the new major.

Please close this issue if you believe this is the intended behavior going forwards.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.