Skip to content

Commit

Permalink
Assets: repair inline add
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jun 12, 2024
1 parent d1494eb commit edee4d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion assets/plugins/features/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class InlinePlugin implements DatagridPlugin {
"input:not([readonly]), textarea:not([readonly])"
)?.focus();
}
return;
}

if (payload._datagrid_inline_editing) {
Expand All @@ -57,6 +56,20 @@ export class InlinePlugin implements DatagridPlugin {
});
});

datagrid.el.querySelectorAll<HTMLElement>(".datagrid-inline-add input").forEach(inputEl => {
inputEl.addEventListener("keydown", e => {
if (!isEnter(e)) return;

e.stopPropagation();
e.preventDefault();

return inputEl
.closest("tr")
?.querySelector<HTMLElement>(".col-action-inline-edit [name='inline_add[submit]']")
?.click();
});
});

datagrid.el.querySelectorAll<HTMLElement>("[data-datagrid-cancel-inline-add]").forEach(cancel => {
cancel.addEventListener("mouseup", e => {
if (e.button === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/datagrid.latte
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
{var $col = 'col-' . $key}

{var $td = clone $column->getElementForRender('td', $key)}
{var $td->class[] = 'datagrid-inline-edit'}
{var $td->class[] = 'datagrid-inline-add'}
{$td->startTag()|noescape}
{if isset($filter['inline_add'][$key])}
{if $filter['inline_add'][$key] instanceof \Nette\Forms\Container}
Expand Down

0 comments on commit edee4d6

Please sign in to comment.