-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/vertical spacing #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/vertical spacing #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes vertical spacing issues caused by expandable text affecting layout and adds window resize handling. The expandable text component was previously pushing the re-run button down, and the app wasn't responding to window resizes.
Key Changes:
- Introduced dynamic height calculation using a custom hook that responds to window resize events
- Added state management to track description height changes when text expands/collapses
- Refactored component to use calculated heights instead of CSS-based height calculations
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hooks/useSiderHeight.tsx | New hook that calculates and updates sidebar height on window resize |
| src/constants.ts | New constants file defining component height values |
| src/components/ExpandableText/index.tsx | Refactored component with height tracking callback and expand/collapse state |
| src/components/PackingInput/index.tsx | Integrated height calculations and passes computed heights to child components |
| src/components/RecipeForm/index.tsx | Updated to accept and apply dynamic height prop |
| src/components/RecipeForm/style.css | Removed static CSS height calculation |
| src/components/PackingInput/style.css | Removed unused recipe-content height CSS |
| src/App.tsx | Applied dynamic sidebar height from hook |
| src/App.css | Removed static CSS height calculation for sidebar |
| src/components/ExpandableDescription/index.tsx | Deleted old component file (moved to ExpandableText) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
…ellpack-client into fix/vertical-spacing
| @@ -0,0 +1,57 @@ | |||
| import { Typography } from "antd"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this folder so the component name matched the file name
| const [isExpanded, setIsExpanded] = useState<boolean>(false); | ||
| const ref = useRef<HTMLParagraphElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| setCurrentHeight( | ||
| (ref.current?.clientHeight || DEFAULT_DESCRIPTION_HEIGHT) + | ||
| TEXT_BOTTOM_MARGIN | ||
| ); | ||
| }, [isExpanded, setCurrentHeight]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are the main changes, I needed to have a way of tracking after the re-render was complete to then get the new height of the element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ellpack-client into fix/vertical-spacing
interim17
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good on my machine
|
Thao made this request on slack (it's also in the design doc)
Does it make sense to do this as part of this PR, or as a follow up ticket? |
ah thanks! yeah, I think it makes sense to re-work this pr with that in mind. I'll convert this to a draft |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| function handleResize() { | ||
| setSiderHeight(window.innerHeight - HEADER_HEIGHT - FOOTER_HEIGHT); | ||
| } | ||
| window.addEventListener("resize", handleResize); | ||
| return () => { | ||
| window.removeEventListener("resize", handleResize); | ||
| }; | ||
| }, []); |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The height calculation logic is duplicated in the initial state (line 7) and the resize handler (line 12). Extract this into a helper function to avoid duplication and ensure consistency.
it's now updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (ref.current?.clientHeight || DEFAULT_DESCRIPTION_HEIGHT) + | ||
| TEXT_BOTTOM_MARGIN | ||
| ); | ||
| }, [isExpanded, setCurrentHeight]); |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useLayoutEffect hook is missing text in its dependency array. When the text changes, useEffect resets isExpanded to false, but the height may not be recalculated if setCurrentHeight is a stable reference. This can lead to stale height values. Add text to the dependency array of useLayoutEffect.
| }, [isExpanded, setCurrentHeight]); | |
| }, [isExpanded, setCurrentHeight, text]); |
| const getAvailableHeight = useCallback(() => { | ||
| return siderHeight - descriptionHeight - SELECT_HEIGHT; | ||
| }, [siderHeight, descriptionHeight]); | ||
|
|
||
| useEffect(() => { | ||
| const newAvailableHeight = getAvailableHeight(); | ||
| setAvailableRecipeHeight(newAvailableHeight); | ||
| }, [getAvailableHeight]); |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getAvailableHeight callback and the effect that uses it are redundant. The effect can directly calculate and set the available height without the intermediate callback, simplifying the code and removing unnecessary memoization.
| const getAvailableHeight = useCallback(() => { | |
| return siderHeight - descriptionHeight - SELECT_HEIGHT; | |
| }, [siderHeight, descriptionHeight]); | |
| useEffect(() => { | |
| const newAvailableHeight = getAvailableHeight(); | |
| setAvailableRecipeHeight(newAvailableHeight); | |
| }, [getAvailableHeight]); | |
| // Update availableRecipeHeight when siderHeight or descriptionHeight changes | |
| useEffect(() => { | |
| const newAvailableHeight = siderHeight - descriptionHeight - SELECT_HEIGHT; | |
| setAvailableRecipeHeight(newAvailableHeight); | |
| }, [siderHeight, descriptionHeight]); |
Problem
the expandable text pushed the re-run button down
Also, we weren't resizing the app if someone resized the window
EDIT after comment:
we want the tab headers and description to be fixed at the top
Solution
used a hook and some state management to re-calc heights after collapse/expand text
Type of change
Please delete options that are not relevant.
Steps to Verify: