Skip to content

Commit

Permalink
Merge pull request #450 from NBISweden/dev/comments-esc
Browse files Browse the repository at this point in the history
Add ways to close the comment area
  • Loading branch information
HenrikeW authored May 16, 2022
2 parents 939c4b9 + 0023c24 commit 2ecaf72
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/components/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Cell = ({
const [showCommentArea, setShowCommentArea] = useState<boolean>(false);
const [areaComments, setAreaComments] = useState<string>(null);
const onCommentButtonClick = () => {
setShowCommentArea(!showCommentArea);
setShowCommentArea(true);
};
const onCommentUpdate = (e: any) => {
setAreaComments(e.target.value);
Expand All @@ -44,6 +44,13 @@ export const Cell = ({
}
}
};
const onEscapeArea = (e: any) => {
{
if (e.key === "Escape") {
setShowCommentArea(false);
}
}
};
const onCellChange = (event: any) => {
//makes sure that users can only input positive numbers up to 999.99999999...
//with an unlimited number of decimals behind the delimiter
Expand Down Expand Up @@ -105,6 +112,8 @@ export const Cell = ({
name="comments"
rows={2}
maxLength={1000}
onKeyUp={onEscapeArea}
onBlur={() => setShowCommentArea(false)}
defaultValue={areaComments !== null ? areaComments : comments}
/>
<button
Expand Down

0 comments on commit 2ecaf72

Please sign in to comment.