Open caodangtinh opened 5 months ago
I understand the intent of this request. But I'm curious, how would you then suggest handle normal single-click selection criteria in the tree which will select a node, but not open it.
@sageacy I would handle that with a modifier key plus click, like a web select list
@sageacy +1 for single click to activate.
IMO, tedious double click to activate and lack of modifier key support are the primary blocker for adopting Link Map vs nearly any other tab manager extension or even built-in Vertical Tabs. I've never seen another extension that requires double click to activate a tab, and it makes it far too tedious to use vs any other alternative without it.
This usually can be implemented without even requiring use of modifier keys (though I suggest supporting those as well). As the primary use case for single click (without modifier keys) other than activation is dragging, you can handle that easily as described below.
Otherwise, clicking on buttons like +/- and hover buttons etc should work the same either way (not activating a tab, just ignoring as already handled by the clicked button).
That said, I would highly suggest you also support modifier keys and have the following as the default mode of operation, consistent with most tab managers and tree view controls in general.
You can see as examples of typically expected and useful time saving functionality for interacting with tab sidebars:
If desired, you could have an option "Double click to switch tabs" mode (but not enabled by default IMO):
Differentiating between single click to activate vs drag is usually handled simply by a drag flag set if mousemove occurs after mousedown and before mouseup. Sometimes can be limited to movement threshold for unintentional slight movements.
let drag = false;
document.addEventListener('mousedown', () => drag = false);
document.addEventListener('mousemove', () => drag = true);
document.addEventListener('mouseup', () => drag ? ondrag() : onclick()));
Alternatively, you can use document.onclick vs document.ondrag events with elements that have draggable=true, which essentially does the above automatically.
You can see examples of both techniques here: https://www.geeksforgeeks.org/how-to-differentiate-mouse-click-and-drag-event-using-javascript/
The library you use should probably already differentiate between click vs double click events (eg. as used at https://github.com/GarinZ/link-map/blob/c275525f66b31ddd91b3530588d4e277100671df/src/tree/features/tab-master-tree/fancy-tab-master-tree.ts#L111 ) but if not you can trigger a delayed click event with timeout like 300ms (ideally configurable, possiblye after mouseup) and cancel single click event if a double click event gets triggered instead.
If desired, you can detect touch (vs click) events and have touch perform same as click but with single click activation disabled, as if was in "Double click to switch tabs" mode, done like shown at: https://www.geeksforgeeks.org/how-to-detect-touch-screen-device-using-javascript/
But even then, I suggest that only be the case when detecting actual touch event (as shown in example), not just because a touch screen capability exists, as often goes unused with mouse or touchpad (as even supported on iPad Pro etc) (unless you add options for explicitly enabled and persisted Touch Mode with easy toggle in sidebar toolbar.)
If touch screen is detected, however, you might want to also show in context menu the following:
Checkbox selection (via option 2 or 3) is useful in general even with Ctrl and Shift multi-selection, but lower priority as long as at least those basic expected Ctrl/Shift multi-select modes are supported.
This was exactly what I wanted, and it bothered me to have to double-click to switch. I have an alternative solution to how to differentiate between switching and expanding tab pages, just change the treemap to a style like below - just enlarge the expand and zoom out buttons to make them easy to click. This way, it's easy to switch between tabs and open collapsed content
Hi, can we switch between tabs with a single click instead of a double click? It has better user experience I think.