Skip to content

Commit 70e2a50

Browse files
fix: The Web UX is intentionally not revealing references when clicked to display (#974)
Co-authored-by: Arpit Gaur <gaurarpit@gmail.com>
1 parent c323d78 commit 70e2a50

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

code/frontend/src/components/Answer/Answer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useMemo, useState } from "react";
1+
import { useEffect, useMemo, useState, useRef } from "react";
22
import { useBoolean } from "@fluentui/react-hooks"
33
import { FontIcon, Stack, Text } from "@fluentui/react";
44

@@ -29,14 +29,17 @@ export const Answer = ({
2929

3030
const parsedAnswer = useMemo(() => parseAnswer(answer), [answer]);
3131
const [chevronIsExpanded, setChevronIsExpanded] = useState(isRefAccordionOpen);
32-
32+
const refContainer = useRef<HTMLDivElement>(null);
3333
const handleChevronClick = () => {
3434
setChevronIsExpanded(!chevronIsExpanded);
3535
toggleIsRefAccordionOpen();
3636
};
3737

3838
useEffect(() => {
3939
setChevronIsExpanded(isRefAccordionOpen);
40+
if(chevronIsExpanded && refContainer.current){
41+
refContainer.current.scrollIntoView({ behavior:'smooth'});
42+
}
4043
}, [isRefAccordionOpen]);
4144

4245
const createCitationFilepath = (citation: Citation, index: number, truncate: boolean = false) => {
@@ -104,11 +107,11 @@ export const Answer = ({
104107

105108
</Stack>
106109
{chevronIsExpanded &&
107-
<div style={{ marginTop: 8, display: "flex", flexDirection: "column", height: "100%", gap: "4px", maxWidth: "100%" }}>
110+
<div ref={refContainer} style={{ marginTop: 8, display: "flex", flexDirection: "column", height: "100%", gap: "4px", maxWidth: "100%" }}>
108111
{parsedAnswer.citations.map((citation, idx) => {
109112
return (
110113
<span title={createCitationFilepath(citation, ++idx)} key={idx} onClick={() => onCitationClicked(citation)} className={styles.citationContainer}>
111-
<div className={styles.citation}>{idx}</div>
114+
<div className={styles.citation} key={idx}>{idx}</div>
112115
{createCitationFilepath(citation, idx, true)}
113116
</span>);
114117
})}

0 commit comments

Comments
 (0)