Search code examples
react-admin

How to change the delete confirmation dialog title?


The delete confirmation dialog show the resource name and #id as title. How to change this title to the one defined in Edit object where undoable={false} is set ?

And for the bulk delete confirmation dialog it takes the resource name instead of the resource label, how to also change this behavior ?


Solution

  • The DeleteButton / BulkDeleteButton components have the confirmTitle / confirmContent properties, there you can set your own title and content:

    const MyActions = props => (
      <TopToolbar>
        <DeleteButton
          undoable={false}
          confirmTitle={'My Title'}  // 'resources.my_res.delete.title'
          confirmContent={'My Content'}
        />
      </TopToolbar>
    )
    
    const MyBulkActionButtons = props => (
      <>
        <BulkDeleteButton
          undoable={false}
          confirmTitle={'My Title'}
          confirmContent={'My Content'}
          {...props}
        />
      </>
    )
    
    <List actions={<MyActions />} bulkActionButtons={<MyBulkActionButtons />} />
    <Edit actions={<MyActions />} />