Skip to content

Commit add4041

Browse files
committed
fix(chat): spacing and InputBar resize
1 parent 9308c37 commit add4041

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

chat/input-bar/src/InputBar/InputBar.styles.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import {
1515
Variant,
1616
} from '@leafygreen-ui/tokens';
1717

18+
/**
19+
* when `InputBar` is used in a drawer (or other context that restricts
20+
* the width of the container), we need to set a minimum width so that
21+
* `react-textarea-autosize` can properly calculate the initial height
22+
* of the textarea element.
23+
*/
24+
const TEXT_AREA_MIN_WIDTH = 150;
25+
1826
const baseFormStyles = css`
1927
width: 100%;
2028
`;
@@ -100,6 +108,7 @@ export const getContentWrapperStyles = ({
100108
});
101109

102110
const getBaseTextAreaStyles = ({ theme }: { theme: Theme }) => css`
111+
min-width: ${TEXT_AREA_MIN_WIDTH}px;
103112
width: 100%;
104113
font-size: ${BaseFontSize.Body1}px;
105114
font-family: ${fontFamilies.default};

chat/message-feed/src/MessageFeed/MessageFeed.styles.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ export const scrollContainerStyles = css`
3939
overflow-y: scroll;
4040
scroll-behavior: smooth;
4141
position: relative;
42-
padding: 0 ${spacing[400]}px ${spacing[400]}px;
42+
padding: 0 ${spacing[400]}px;
4343
display: flex;
4444
flex-direction: column;
4545
gap: ${spacing[400]}px;
4646
`;
47+
48+
// Ensures the intercept element is visible and considered by the browser
49+
export const interceptStyles = css`
50+
min-height: 1px;
51+
`;

chat/message-feed/src/MessageFeed/MessageFeed.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import LeafyGreenProvider, {
1414

1515
import { ScrollToLatestButton } from '../ScrollToLatestButton';
1616

17-
import { getWrapperStyles, scrollContainerStyles } from './MessageFeed.styles';
17+
import {
18+
getWrapperStyles,
19+
interceptStyles,
20+
scrollContainerStyles,
21+
} from './MessageFeed.styles';
1822
import { MessageFeedProps } from '.';
1923

2024
export const MessageFeed = forwardRef(
@@ -106,10 +110,10 @@ export const MessageFeed = forwardRef(
106110
>
107111
<div className={scrollContainerStyles} ref={scrollContainerRef}>
108112
{/* Empty span element used to track if container can scroll up */}
109-
<span ref={topInterceptRef} />
113+
<span className={interceptStyles} ref={topInterceptRef} />
110114
{children}
111115
{/* Empty span element used to track if container can scroll down */}
112-
<span ref={bottomInterceptRef} />
116+
<span className={interceptStyles} ref={bottomInterceptRef} />
113117
</div>
114118
<ScrollToLatestButton
115119
darkMode={darkMode}

0 commit comments

Comments
 (0)