silevis / reactgrid

Add spreadsheet-like behavior to your React app

Home Page:https://reactgrid.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chevron cell onCellChanged not triggered when ChevronCell is nonEditable

tprebs opened this issue · comments

Describe the bug
I imagine this is quite a common usecase. A ChevronCell on a non-editable header row where the header is used to toggle the group of rows below. Currently this does not work (in v4) as onCellChanged not triggered when the icon is clicked

Current behavior
Chevron cell onCellChanged not triggered when ChevronCell is nonEditable.

Expected behavior
Chevron cell onCellChanged should be triggered when ChevronCell is nonEditable.

Screenshots or gifs
example codebase
https://codesandbox.io/p/sandbox/reactgrid-chevron-cell-example-non-editable-fields-hmrysz?file=%2Fsrc%2Frows.ts%3A9%2C11

@tprebs This is a question

It happens because there is an additional condition !newCell.nonEditable inside tryAppendChange that prevents toggling the rows below the parent chevron cell.

https://github.com/silevis/reactgrid/blob/6673a044539301c2211a6ad5562d7048abeb81f8/src/lib/Functions/tryAppendChange.ts#L12C1-L12C5

There is also an option to create own cell template that will work in the way you intended:
https://reactgrid.com/docs/4.0/5-create-your-own-cell-template/

I think there is no need to judge when ChevronCell in tryAppendChange.ts ! newCell.nonEditable

It happens because there is an additional condition !newCell.nonEditable inside tryAppendChange that prevents toggling the rows below the parent chevron cell.

https://github.com/silevis/reactgrid/blob/6673a044539301c2211a6ad5562d7048abeb81f8/src/lib/Functions/tryAppendChange.ts#L12C1-L12C5

There is also an option to create own cell template that will work in the way you intended: https://reactgrid.com/docs/4.0/5-create-your-own-cell-template/

This is exactly what I did. I have my own cell template called CollapsibleHeader which shares the same behaviour. Not firing onCellChanged events for nonEditable fields makes sense. I don't remember coming across that in the documentation so it may be worth documenting.