Skip to content

Commit bcf948c

Browse files
committed
maintain height
1 parent 9335fc8 commit bcf948c

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/components/ExpandableText/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ const ExpandableText = ({ text, setCurrentHeight }: ExpandableTextProps) => {
3030
const [isExpanded, setIsExpanded] = useState<boolean>(false);
3131
const ref = useRef<HTMLParagraphElement>(null);
3232

33+
useEffect(() => {
34+
setIsExpanded(false);
35+
}, [text]);
36+
3337
useEffect(() => {
3438
setCurrentHeight(
3539
(ref.current?.clientHeight || DEFAULT_DESCRIPTION_HEIGHT) +
3640
TEXT_BOTTOM_MARGIN
3741
);
38-
}, [isExpanded, setCurrentHeight]);
42+
}, [isExpanded, setCurrentHeight, text]);
3943
return (
4044
<Paragraph
4145
ref={ref}

src/components/PackingInput/index.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,15 @@ const PackingInput = (props: PackingInputProps): JSX.Element => {
4343
const storeStartPacking = useStartPacking();
4444
const siderHeight = useSiderHeight();
4545

46-
const [availableRecipeHeight, setAvailableRecipeHeight] = useState<number>(
47-
siderHeight -
48-
DEFAULT_DESCRIPTION_HEIGHT -
49-
SELECT_HEIGHT -
50-
TEXT_BOTTOM_MARGIN
51-
);
5246
const [descriptionHeight, setDescriptionHeight] = useState<number>(
53-
DEFAULT_DESCRIPTION_HEIGHT
47+
DEFAULT_DESCRIPTION_HEIGHT + TEXT_BOTTOM_MARGIN
48+
);
49+
const [availableRecipeHeight, setAvailableRecipeHeight] = useState<number>(
50+
siderHeight - descriptionHeight - SELECT_HEIGHT
5451
);
5552

5653
const getAvailableHeight = useCallback(() => {
57-
return (
58-
siderHeight - descriptionHeight - SELECT_HEIGHT - TEXT_BOTTOM_MARGIN
59-
);
54+
return siderHeight - descriptionHeight - SELECT_HEIGHT;
6055
}, [siderHeight, descriptionHeight]);
6156

6257
useEffect(() => {

src/components/RecipeForm/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const RecipeForm = ({ onStartPacking, availableHeight }: RecipeFormProps) => {
4949
>
5050
<Button
5151
onClick={onStartPacking}
52+
className="packing-button"
5253
color="primary"
5354
variant="filled"
5455
disabled={isPacking || isOriginalRecipe}

src/components/RecipeForm/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
flex-direction: column;
44
justify-content: space-between;
55
}
6+
7+
.packing-button {
8+
margin-bottom: 20px;
9+
}

src/hooks/useSiderHeight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from "react";
22
const HEADER_HEIGHT = 48;
3-
const FOOTER_HEIGHT = 64;
3+
const FOOTER_HEIGHT = 51;
44

55
export function useSiderHeight() {
66
const [siderHeight, setSiderHeight] = useState<number>(

0 commit comments

Comments
 (0)