diff --git a/src/resources/views/crud/inc/datatables_logic.blade.php b/src/resources/views/crud/inc/datatables_logic.blade.php index 908b577c37..3f77407d7d 100644 --- a/src/resources/views/crud/inc/datatables_logic.blade.php +++ b/src/resources/views/crud/inc/datatables_logic.blade.php @@ -403,21 +403,23 @@ function resizeCrudTableColumnWidths() { function formatActionColumnAsDropdown() { // Get action column const actionColumnIndex = $('#crudTable').find('th[data-action-column=true]').index(); - if (actionColumnIndex !== -1) { - $('#crudTable tr').each(function (i, tr) { - const actionCell = $(tr).find('td').eq(actionColumnIndex); - const actionButtons = $(actionCell).find('a.btn.btn-link'); - // Wrap the cell with the component needed for the dropdown - actionCell.wrapInner('
'); - actionCell.wrapInner(''); - // Prepare buttons as dropdown items - actionButtons.map((index, action) => { - $(action).addClass('dropdown-item').removeClass('btn btn-sm btn-link'); - $(action).find('i').addClass('me-2 text-primary'); - }); - actionCell.prepend('{{ trans('backpack::crud.actions') }}'); + if (actionColumnIndex === -1) return; + + $('#crudTable tbody tr').each(function (i, tr) { + const actionCell = $(tr).find('td').eq(actionColumnIndex); + if(actionCell.find('.actions-buttons-column').length) return; + + // Wrap the cell with the component needed for the dropdown + actionCell.wrapInner(''); + actionCell.wrapInner(''); + + // Prepare buttons as dropdown items + actionCell.find('a.btn.btn-link').each((index, action) => { + $(action).addClass('dropdown-item').removeClass('btn btn-sm btn-link'); + $(action).find('i').addClass('me-2 text-primary'); }); - } + actionCell.prepend('{{ trans('backpack::crud.actions') }}'); + }); }