Open only the info popover when a calendar bar is tapped
On touch screens a tap on a task bar both showed its info popover and opened the schedule dialog. A tap now only opens the popover, which stays open until something else is tapped, and the popover's own "Open schedule" button opens the dialog. Mouse clicks and Enter still open the dialog directly. The popover is no longer a tooltip since it holds a button, and the bar's aria-describedby points only at the details. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -9,7 +9,10 @@
|
||||
* the same changes with the keyboard. Escape cancels a drag.
|
||||
*
|
||||
* Hovering or focusing a bar shows its info popover (the job's basic
|
||||
* details); the pointer may move onto it, and Escape closes it.
|
||||
* details); the pointer may move onto it, and Escape closes it. A mouse
|
||||
* click or Enter on a bar opens its dialog. On a touch screen a tap only
|
||||
* opens the popover (a tap would otherwise both show it and open the
|
||||
* dialog), and the popover's own button opens the dialog.
|
||||
*/
|
||||
const DRAG_THRESHOLD_PX = 5;
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
@@ -40,6 +43,8 @@ export function taskCalendar(canManage) {
|
||||
|
||||
info: null,
|
||||
infoTimer: null,
|
||||
infoHeld: false,
|
||||
touched: false,
|
||||
|
||||
/**
|
||||
* Shows the info popover of a bar next to it. Not while dragging.
|
||||
@@ -86,6 +91,10 @@ export function taskCalendar(canManage) {
|
||||
this.infoTimer = setTimeout(() => {
|
||||
const popover = document.getElementById(id);
|
||||
|
||||
if (this.infoHeld && this.info === popover) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (popover?.matches(':popover-open')) {
|
||||
popover.hidePopover();
|
||||
}
|
||||
@@ -103,6 +112,7 @@ export function taskCalendar(canManage) {
|
||||
|
||||
closeInfo() {
|
||||
this.keepInfo();
|
||||
this.infoHeld = false;
|
||||
|
||||
if (this.info?.matches(':popover-open')) {
|
||||
this.info.hidePopover();
|
||||
@@ -111,8 +121,80 @@ export function taskCalendar(canManage) {
|
||||
this.info = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* A tap on a popover keeps it open until something outside it is tapped.
|
||||
*/
|
||||
holdInfo() {
|
||||
this.keepInfo();
|
||||
this.infoHeld = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Closes the popover when a tap or click lands outside it and its bar.
|
||||
*/
|
||||
dismissInfo(event) {
|
||||
if (this.info && !this.info.contains(event.target) && !event.target.closest?.('[data-calendar-bar]')) {
|
||||
this.closeInfo();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Keyboard focus leaving the popover (not back to its bar) closes it.
|
||||
*/
|
||||
leaveInfo(event, id) {
|
||||
const next = event.relatedTarget;
|
||||
|
||||
if (next && (next.closest?.(`#${id}`) || next.getAttribute?.('aria-describedby') === `${id}-details`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.hideInfo(id, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* A bar's own blur closes its popover unless focus moves into it.
|
||||
*/
|
||||
blurBar(event, id) {
|
||||
if (event.relatedTarget?.closest?.(`#${id}`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.hideInfo(id, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* A mouse click or Enter opens the dialog; a tap shows the popover,
|
||||
* whose button opens the dialog.
|
||||
*/
|
||||
clickBar(bar, id, open) {
|
||||
const touched = this.touched;
|
||||
this.touched = false;
|
||||
|
||||
if (this.consumeDrag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (touched) {
|
||||
this.showInfo(bar, id);
|
||||
this.holdInfo();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
open();
|
||||
},
|
||||
|
||||
/**
|
||||
* The popover's button: close it and open the dialog.
|
||||
*/
|
||||
openFromInfo(open) {
|
||||
this.closeInfo();
|
||||
open();
|
||||
},
|
||||
|
||||
begin(event, mode, bar) {
|
||||
this.closeInfo();
|
||||
this.touched = event.pointerType === 'touch' || event.pointerType === 'pen';
|
||||
|
||||
if (!canManage || event.button !== 0 || event.pointerType === 'touch') {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user