Fix RowClickFunction type to accept false. #8561
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DatagridRow
'srowClick
property may be provided with a function, that may return a string (to trigger navigation) orfalse
(in order to skip navigation). At least the code would allow to do that, see https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx#L113However typing restricts this (via
RowClickFunction
) to just support string return types (or promises there of).This PR changes the type to allow
false
to be returned as well (both directly or with promise).Please note that there are further inconsistencies with typing of
rowClick
onDatagrid
itself andDatagridBody
, which both disallowrowClick={false}
(opposed toDatagridRow
). FurthermoreDatagridRow.propTypes.rowClick
does not allowfalse
value (i.e. conflicts with typing).This PR ignores this so far, since I'm not directly affected by that and I wasn't sure whether to fix that. Let me know if I should.