Skip to content

Commit

Permalink
Cell edit improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jul 4, 2020
1 parent 25ec783 commit 9ba8911
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/components/datatable/BodyCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ export default {
this.children = this.$children;
},
updated() {
if (this.d_editing) {
let focusable = DomHandler.findSingle(this.$el, 'input');
if (focusable) {
focusable.focus();
}
let query = this.editMode === 'row' ? '[autofocus]' : 'input';
let focusable = DomHandler.findSingle(this.$el, query);
if (focusable && document.activeElement != focusable) {
focusable.focus();
}
},
methods: {
Expand Down
5 changes: 0 additions & 5 deletions src/components/datatable/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1963,11 +1963,6 @@ export default {
display: none;
}
/* Edit */
.p-datatable .p-datatable-tbody > tr > td.p-cell-editing .p-component {
width: 100%;
}
.p-datatable .p-row-editor-init,
.p-datatable .p-row-editor-save,
.p-datatable .p-row-editor-cancel {
Expand Down
2 changes: 1 addition & 1 deletion src/views/datatable/DataTableDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ export default {
<Column field="vin" header="Vin"></Column>
<Column field="year" header="Year">
<template #editor="slotProps">
<InputText v-model="slotProps.data[slotProps.column.field]" />
<InputText v-model="slotProps.data[slotProps.column.field]" autofocus/>
</template>
</Column>
<Column field="brand" header="Brand">
Expand Down
6 changes: 3 additions & 3 deletions src/views/datatable/DataTableEditDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
</div>

<div class="content-section implementation">
<div class="content-section implementation p-fluid">
<div class="card">
<h5>Basic Cell Editing</h5>
<p>Simple editors with v-model.</p>
Expand Down Expand Up @@ -62,7 +62,7 @@
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel">
<Column field="code" header="Code">
<template #editor="slotProps">
<InputText v-model="slotProps.data[slotProps.column.field]" />
<InputText v-model="slotProps.data[slotProps.column.field]" autofocus />
</template>
</Column>
<Column field="name" header="Name">
Expand Down Expand Up @@ -149,7 +149,7 @@
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel"&gt;
&lt;Column field="code" header="Code"&gt;
&lt;template #editor="slotProps"&gt;
&lt;InputText v-model="slotProps.data[slotProps.column.field]" /&gt;
&lt;InputText v-model="slotProps.data[slotProps.column.field]" autofocus /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="name" header="Name"&gt;
Expand Down

0 comments on commit 9ba8911

Please sign in to comment.