revert: restore auto-hiding overlay scrollbars
This commit is contained in:
@@ -25,12 +25,6 @@ const isSameThumbMetrics = (a: ThumbMetrics, b: ThumbMetrics): boolean => {
|
|||||||
return Math.abs(a.length - b.length) < METRIC_EPSILON && Math.abs(a.offset - b.offset) < METRIC_EPSILON;
|
return Math.abs(a.length - b.length) < METRIC_EPSILON && Math.abs(a.offset - b.offset) < METRIC_EPSILON;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Desktop shells (Electron, VS Code webview) use persistent, not
|
|
||||||
// auto-hiding, scrollbars. Reads the same `desktop-runtime` root class that
|
|
||||||
// index.css keys off, so JS and CSS never disagree on what counts as desktop.
|
|
||||||
const isDesktopScrollbarRuntime = (): boolean =>
|
|
||||||
typeof document !== "undefined" && document.documentElement.classList.contains("desktop-runtime");
|
|
||||||
|
|
||||||
const OverlayScrollbarComponent: React.FC<OverlayScrollbarProps> = ({
|
const OverlayScrollbarComponent: React.FC<OverlayScrollbarProps> = ({
|
||||||
containerRef,
|
containerRef,
|
||||||
minThumbSize = 32,
|
minThumbSize = 32,
|
||||||
@@ -134,15 +128,8 @@ const OverlayScrollbarComponent: React.FC<OverlayScrollbarProps> = ({
|
|||||||
if (isHoveringRef.current) {
|
if (isHoveringRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Desktop shells keep the thumb visible once shown instead of
|
|
||||||
// auto-hiding it after a delay. userIntentOnly callers (e.g. chat
|
|
||||||
// auto-follow scroll) opt out of persistence on purpose, so they keep
|
|
||||||
// the existing auto-hide behavior even on desktop.
|
|
||||||
if (isDesktopScrollbarRuntime() && !userIntentOnly) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hideTimeoutRef.current = setTimeout(() => setVisible(false), hideDelayMs);
|
hideTimeoutRef.current = setTimeout(() => setVisible(false), hideDelayMs);
|
||||||
}, [hideDelayMs, userIntentOnly]);
|
}, [hideDelayMs]);
|
||||||
|
|
||||||
const markUserIntent = React.useCallback(() => {
|
const markUserIntent = React.useCallback(() => {
|
||||||
lastUserIntentAtRef.current = Date.now();
|
lastUserIntentAtRef.current = Date.now();
|
||||||
@@ -175,10 +162,7 @@ const OverlayScrollbarComponent: React.FC<OverlayScrollbarProps> = ({
|
|||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
// On desktop shells, show the thumb immediately if content overflows
|
setVisible(false);
|
||||||
// instead of waiting for the first scroll event (persistent affordance,
|
|
||||||
// matching native desktop scrollbar conventions).
|
|
||||||
setVisible(isDesktopScrollbarRuntime() && !userIntentOnly);
|
|
||||||
|
|
||||||
const onScroll = () => handleScroll();
|
const onScroll = () => handleScroll();
|
||||||
const onKeyDown = (event: KeyboardEvent) => {
|
const onKeyDown = (event: KeyboardEvent) => {
|
||||||
|
|||||||
@@ -1804,10 +1804,8 @@ input[aria-label="Terminal input"] {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Settings dialog: hide the overlay scrollbar on mobile/web; wheel/keyboard
|
/* Settings dialog: hide the overlay scrollbar; wheel/keyboard scroll still works. */
|
||||||
scroll still works. Desktop shells keep the persistent scrollbar so the
|
[data-settings-view="true"] .overlay-scrollbar {
|
||||||
Settings sub-panels aren't left with no scroll affordance at all. */
|
|
||||||
html:not(.desktop-runtime) [data-settings-view="true"] .overlay-scrollbar {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user