Skip to content

Commit

Permalink
2438 annotator overflows (#2442)
Browse files Browse the repository at this point in the history
* Add marginTop parameter to buttongroup component

* Adapt the annotator height to the class selector
  • Loading branch information
adammertel authored Nov 12, 2024
1 parent 6acc9bb commit b1acb56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export const TextAnnotator = ({
</StyledCanvasWrapper>

{annotator && (
<ButtonGroup>
<ButtonGroup marginTop>
<Button
key={EditMode.HIGHLIGHT}
icon={<FaPen size={11} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface ButtonGroup {
$noMarginRight?: boolean;
column?: boolean;
marginBottom?: boolean;
marginTop?: boolean;
height?: number;
}
export const ButtonGroup = styled.div.attrs({
Expand All @@ -13,6 +14,7 @@ export const ButtonGroup = styled.div.attrs({
display: flex;
height: ${({ height }) => (height ? `${height / 10}rem` : "")};
flex-direction: ${({ column }) => (column ? "column" : "row")};
margin-top: ${({ marginTop, theme }) => (marginTop ? theme.space[2] : "")};
margin-bottom: ${({ marginBottom, theme }) =>
marginBottom ? theme.space[2] : ""};
> button:not(:last-child),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Button, Loader } from "components";
import Dropdown, { EntitySuggester, EntityTag } from "components/advanced";
import TextAnnotator from "components/advanced/Annotator/Annotator";
import AnnotatorProvider from "components/advanced/Annotator/AnnotatorProvider";
import React, { useEffect, useMemo, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import { FaLongArrowAltRight, FaUnlink } from "react-icons/fa";
import { GrDocumentMissing } from "react-icons/gr";
import { TbAnchorOff } from "react-icons/tb";
Expand All @@ -20,6 +20,7 @@ import {
StyledDocumentTag,
StyledDocumentTitle,
} from "../StatementLitBoxStyles";
import useResizeObserver from "use-resize-observer";

interface StatementListTextAnnotator {
statements: IResponseStatement[];
Expand Down Expand Up @@ -206,6 +207,9 @@ export const StatementListTextAnnotator: React.FC<
return false;
}, [selectedDocument, territoryId]);

const { ref: selectorRef, height: selectorHeight = 0 } =
useResizeObserver<HTMLDivElement>();

return (
<animated.div style={animatedStyle}>
<div
Expand Down Expand Up @@ -305,6 +309,7 @@ export const StatementListTextAnnotator: React.FC<
)}
</div>

{/* Class selector */}
{selectedResource !== false && selectedResource?.data?.documentId && (
<div
style={{
Expand All @@ -313,6 +318,7 @@ export const StatementListTextAnnotator: React.FC<
gap: "4px",
marginBottom: "5px",
}}
ref={selectorRef}
>
<StyledModeSwitcher style={{ textWrap: "nowrap" }}>
Highlight
Expand Down Expand Up @@ -342,7 +348,7 @@ export const StatementListTextAnnotator: React.FC<
<TextAnnotator
width={
statements.length > 0
? contentWidth - COLLAPSED_TABLE_WIDTH
? contentWidth - COLLAPSED_TABLE_WIDTH - 5
: contentWidth
}
hlEntities={hlEntities}
Expand All @@ -352,7 +358,7 @@ export const StatementListTextAnnotator: React.FC<
thisTerritoryEntityId={territoryId}
initialScrollEntityId={territoryId}
displayLineNumbers={true}
height={contentHeight - 100}
height={contentHeight - selectorHeight - 70}
documentId={selectedDocumentId}
handleCreateStatement={handleCreateStatement}
handleCreateTerritory={handleCreateTerritory}
Expand Down

0 comments on commit b1acb56

Please sign in to comment.