Skip to content

Commit

Permalink
Merge pull request #290 from jxn-30/main
Browse files Browse the repository at this point in the history
feat: add optional `prevent-context-menu-row` prop defaulting to `true`
  • Loading branch information
HC200ok authored Jun 11, 2023
2 parents 5135908 + 329b3b6 commit fd46782
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "HC200ok",
"description": "A customizable and easy-to-use data table component made with Vue.js 3.x.",
"private": false,
"version": "1.5.43",
"version": "1.5.44",
"types": "./types/main.d.ts",
"license": "MIT",
"files": [
Expand Down
8 changes: 7 additions & 1 deletion src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
clickRowToExpand && updateExpandingItemIndexList(index + prevPageEndIndex, item, $event);
}"
@dblclick="($event) => {clickRow(item, 'double', $event)}"
@contextmenu.prevent="($event) => {emits('contextmenuRow', item, $event)}"
@contextmenu="($event) => {contextMenuRow(item, $event)}"
>
<td
v-for="(column, i) in headerColumns"
Expand Down Expand Up @@ -369,6 +369,7 @@ const {
themeColor,
rowsOfPageSeparatorMessage,
showIndexSymbol,
preventContextMenuRow
} = toRefs(props);
// style related computed variables
Expand Down Expand Up @@ -554,6 +555,11 @@ const {
emits,
);
const contextMenuRow = (item: Item, $event: MouseEvent) => {
if (preventContextMenuRow.value) $event.preventDefault();
emits('contextmenuRow', item, $event);
}
// template style generation function
const getColStyle = (header: HeaderForRender): string | undefined => {
const width = header.width ?? (fixedHeaders.value.length ? 100 : null);
Expand Down
4 changes: 4 additions & 0 deletions src/propsWithDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,9 @@ export default {
showIndexSymbol: {
type: String,
default: '#',
},
preventContextMenuRow: {
type: Boolean,
default: true
}
};

0 comments on commit fd46782

Please sign in to comment.