Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(annotation): improve keyboard navigation experience in drawer (#2236)

marliessophie2f6ade935431
diff --git a/web/src/features/manual-scoring/components/AnnotateButton.tsx b/web/src/features/manual-scoring/components/AnnotateButton.tsx
index 98d18a9016..6c7a108683 100644
--- a/web/src/features/manual-scoring/components/AnnotateButton.tsx
+++ b/web/src/features/manual-scoring/components/AnnotateButton.tsx
@@ -594,6 +594,7 @@ export function AnnotateButton({
index,
score,
})}
+ onKeyDown={handleOnKeyDown}
/>
) : config.categories &&
(
@@ -705,3 +706,22 @@ export function AnnotateButton({
</Drawer>
);
}
+
+function handleOnKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ const form = e.currentTarget.form;
+ if (!form) return;
+
+ const currentTabIndex = e.currentTarget.tabIndex;
+ const nextElement = form.querySelector(
+ `[tabindex="${currentTabIndex + 1}"]`,
+ );
+
+ if (nextElement instanceof HTMLElement) {
+ nextElement.focus();
+ } else {
+ e.currentTarget.blur();
+ }
+ }
+}