material-table-core / core

Datatable for React based on material-ui's table with additional features. Support us at https://opencollective.com/material-table-core
https://material-table-core.github.io
MIT License
296 stars 146 forks source link

Child row of a child row does not show "Are you sure you want to delete this row?" #830

Closed KippWade closed 3 months ago

KippWade commented 9 months ago

Describe the bug When using the parent/child option, a child of a child with children will not show the deletion text "Are you sure you want to delete this row?"

To Reproduce https://codesandbox.io/p/sandbox/material-table-core-parent-child-forked-8rk59g

  1. Expand first child level by clicking on the row (codesandbox example, the row is blue)
  2. Expand the second child level by clicking on the embedded row (codesandbox example, the row is green)
  3. On the second level (green row), click the delete trashcan icon
  4. The text "Are you sure you want to delete this row?" does not appear, the row is blank.

Expected behavior Expected to see the default "Are you sure you want to delete this row?" text.

Screenshots image

Desktop:

Domino987 commented 9 months ago

I'll take a look

KippWade commented 9 months ago

With new CodeSandbox rules, I'm not sure you can get to that sandbox now?

Domino987 commented 9 months ago

Yes I cant see it. Thats annoying..

KippWade commented 9 months ago

Should be able to see it now. They defaulted to everything to be private, and I just made it public.

Domino987 commented 9 months ago

Thanks, Ill check it out.

KippWade commented 6 months ago

This is defiantly something to do with using parent/child. For some reason, the delete text just isn't inserted.

I've been looking through code, but haven't been able to find anything obvious as of yet.

KippWade commented 6 months ago

In MTableEditRow, the localization that is passed on non group rows and the nested child rows are coming through differently. I'm trying to trace through where it is getting the different localization objects.

MTableEditRow:

Other edit rows when deleting, the localization.deleteText is displayed: props: localization: { "saveTooltip": "Save", "cancelTooltip": "Cancel", "deleteText": "Are you sure you want to delete this row?" }

when it's child of child, there is no localization.deleteText in this object, but it's in localization.editRow.deleteText.... props: localization: { "addToolTip": "Add", "bulkEditApprove": "Save all changes", "bulkEditCancel": "Discard all changes", "bulkEditTooltip": "Edit All", ... editRow: { "cancelTooltip": "Cancel", "dateTimePickerLocalization": undefined, "deleteText": "Are you sure you want to delete this row?", "saveTooltip": "Save", ... } ... }

Domino987 commented 6 months ago

That seems like an easy fix. Would you mind creating a PR to address this?

KippWade commented 6 months ago

I will create one tonight. If found that if in MTableBodyRow I pass localization.editRow in the create element, it looks to work in every instance.