@@ -28,7 +30,7 @@
| ()
const lastColumn = ref()
const tableRows = ref([[], [], [], [], [], []])
+let focusWithClick = false
+
// todo better way to get Day.js locale object
const firstDayOfWeek = (props.date as any).$locale().weekStart || 7
const WEEKS_CONSTANT = props.date
@@ -365,16 +369,31 @@ const isSelectedCell = (cell: DateCell) => {
)
}
-const handleFocus = (event: Event) => {
- if (!hasCurrent.value && props.selectionMode === 'date') {
- handlePickDate(event, true)
- }
+const handleFocus = (event: FocusEvent) => {
+ if (focusWithClick || hasCurrent.value || props.selectionMode !== 'date')
+ return
+ handlePickDate(event, true)
}
-const handlePickDate = (event: Event, isKeyboardMovement = false) => {
+const handleMouseDown = (event: MouseEvent) => {
+ const target = (event.target as HTMLElement).closest('td')
+ if (!target) return
+ focusWithClick = true
+}
+
+const handleMouseUp = (event: MouseEvent) => {
+ const target = (event.target as HTMLElement).closest('td')
+ if (!target) return
+ focusWithClick = false
+}
+
+const handlePickDate = (
+ event: FocusEvent | MouseEvent,
+ isKeyboardMovement = false
+) => {
const target = (event.target as HTMLElement).closest('td')
- if (!target || target.tagName !== 'TD') return
+ if (!target) return
const row = (target.parentNode as HTMLTableRowElement).rowIndex - 1
const column = (target as HTMLTableCellElement).cellIndex
|