Skip to content

Commit fd46782

Browse files
authored
Merge pull request #290 from jxn-30/main
feat: add optional `prevent-context-menu-row` prop defaulting to `true`
2 parents 5135908 + 329b3b6 commit fd46782

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "HC200ok",
44
"description": "A customizable and easy-to-use data table component made with Vue.js 3.x.",
55
"private": false,
6-
"version": "1.5.43",
6+
"version": "1.5.44",
77
"types": "./types/main.d.ts",
88
"license": "MIT",
99
"files": [

src/components/DataTable.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
clickRowToExpand && updateExpandingItemIndexList(index + prevPageEndIndex, item, $event);
134134
}"
135135
@dblclick="($event) => {clickRow(item, 'double', $event)}"
136-
@contextmenu.prevent="($event) => {emits('contextmenuRow', item, $event)}"
136+
@contextmenu="($event) => {contextMenuRow(item, $event)}"
137137
>
138138
<td
139139
v-for="(column, i) in headerColumns"
@@ -369,6 +369,7 @@ const {
369369
themeColor,
370370
rowsOfPageSeparatorMessage,
371371
showIndexSymbol,
372+
preventContextMenuRow
372373
} = toRefs(props);
373374
374375
// style related computed variables
@@ -554,6 +555,11 @@ const {
554555
emits,
555556
);
556557
558+
const contextMenuRow = (item: Item, $event: MouseEvent) => {
559+
if (preventContextMenuRow.value) $event.preventDefault();
560+
emits('contextmenuRow', item, $event);
561+
}
562+
557563
// template style generation function
558564
const getColStyle = (header: HeaderForRender): string | undefined => {
559565
const width = header.width ?? (fixedHeaders.value.length ? 100 : null);

src/propsWithDefault.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,9 @@ export default {
194194
showIndexSymbol: {
195195
type: String,
196196
default: '#',
197+
},
198+
preventContextMenuRow: {
199+
type: Boolean,
200+
default: true
197201
}
198202
};

0 commit comments

Comments
 (0)