Browse Source

refactor(AdvancedTable): made reset column width on double tap work with touch

Kristian Vos 3 years ago
parent
commit
86d2da73c5
1 changed files with 17 additions and 1 deletions
  1. 17 1
      frontend/src/components/AdvancedTable.vue

+ 17 - 1
frontend/src/components/AdvancedTable.vue

@@ -702,7 +702,9 @@ export default {
 			},
 			addFilterValue: null,
 			showFiltersDropdown: false,
-			showColumnsDropdown: false
+			showColumnsDropdown: false,
+			lastColumnResizerTapped: null,
+			lastColumnResizerTappedDate: 0
 		};
 	},
 	computed: {
@@ -1016,6 +1018,20 @@ export default {
 		},
 		columnResizingStart(column, event) {
 			const eventIsTouch = event.type === "touchstart";
+			if (eventIsTouch) {
+				// Handle double click from touch (if this method is called for the same column twice in a row within one second)
+				if (
+					this.lastColumnResizerTapped === column &&
+					Date.now() - this.lastColumnResizerTappedDate <= 1000
+				) {
+					this.columnResetWidth(column);
+					this.lastColumnResizerTapped = null;
+					this.lastColumnResizerTappedDate = 0;
+					return;
+				}
+				this.lastColumnResizerTapped = column;
+				this.lastColumnResizerTappedDate = Date.now();
+			}
 			this.resizing.resizing = true;
 			this.resizing.resizingColumn = column;
 			this.resizing.width = event.target.parentElement.offsetWidth;