Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3379989
D6052.id20179.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6052.id20179.diff
View Options
diff --git a/web/chat/typeahead-tooltip.react.js b/web/chat/typeahead-tooltip.react.js
--- a/web/chat/typeahead-tooltip.react.js
+++ b/web/chat/typeahead-tooltip.react.js
@@ -7,6 +7,7 @@
import type { InputState } from '../input/input-state';
import {
+ getTypeaheadOverlayScroll,
getTypeaheadTooltipActions,
getTypeaheadTooltipButtons,
getTypeaheadTooltipPosition,
@@ -36,6 +37,8 @@
setChosenPositionInOverlay,
] = React.useState<number>(0);
+ const overlayRef = React.useRef<?HTMLDivElement>();
+
React.useEffect(() => {
setIsVisibleForAnimation(true);
@@ -140,13 +143,27 @@
inputState.setTypeaheadState,
]);
+ React.useEffect(() => {
+ const current = overlayRef.current;
+ if (current) {
+ current.scrollTop = getTypeaheadOverlayScroll(
+ current.scrollTop,
+ chosenPositionInOverlay,
+ );
+ }
+ }, [chosenPositionInOverlay]);
+
const overlayClasses = classNames(css.suggestionsContainer, {
[css.notVisible]: !isVisibleForAnimation,
[css.visible]: isVisibleForAnimation,
});
return (
- <div className={overlayClasses} style={tooltipPositionStyle}>
+ <div
+ ref={overlayRef}
+ className={overlayClasses}
+ style={tooltipPositionStyle}
+ >
{tooltipButtons}
</div>
);
diff --git a/web/utils/typeahead-utils.js b/web/utils/typeahead-utils.js
--- a/web/utils/typeahead-utils.js
+++ b/web/utils/typeahead-utils.js
@@ -153,6 +153,30 @@
});
}
+function getTypeaheadOverlayScroll(
+ currentScrollTop: number,
+ chosenActionPosition: number,
+): number {
+ const upperButtonBoundary = chosenActionPosition * typeaheadStyle.rowHeight;
+ const lowerButtonBoundary =
+ (chosenActionPosition + 1) * typeaheadStyle.rowHeight;
+
+ if (upperButtonBoundary < currentScrollTop) {
+ return upperButtonBoundary;
+ } else if (
+ lowerButtonBoundary - typeaheadStyle.tooltipMaxHeight >
+ currentScrollTop
+ ) {
+ return (
+ lowerButtonBoundary +
+ typeaheadStyle.tooltipVerticalPadding -
+ typeaheadStyle.tooltipMaxHeight
+ );
+ }
+
+ return currentScrollTop;
+}
+
function getTypeaheadTooltipPosition(
textarea: HTMLTextAreaElement,
actionsLength: number,
@@ -193,6 +217,7 @@
getCaretOffsets,
getTypeaheadTooltipActions,
getTypeaheadTooltipButtons,
+ getTypeaheadOverlayScroll,
getTypeaheadTooltipPosition,
positiveModulo,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 8:20 PM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594822
Default Alt Text
D6052.id20179.diff (2 KB)
Attached To
Mode
D6052: [web] Keyboard support for typeahead [12/13] - Scrolling thourgh overlay as user interacts with it
Attached
Detach File
Event Timeline
Log In to Comment