Skip to content

Commit 7079612

Browse files
Merge pull request #773 from thatblindgeye/iss767
fix(MessageBar): updated padding on action buttons
2 parents 9037240 + e689e69 commit 7079612

File tree

7 files changed

+33
-11428
lines changed

7 files changed

+33
-11428
lines changed

packages/module/src/MessageBar/AttachButton.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@
4141
.pf-v6-c-button.pf-chatbot__button--attach.pf-m-compact {
4242
width: 1.5rem;
4343
height: 1.5rem;
44-
padding: var(--pf-t--global--spacer--sm);
4544
align-items: center;
4645
}

packages/module/src/MessageBar/MessageBar.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,22 @@
147147
.pf-chatbot__message-textarea {
148148
font-size: var(--pf-t--global--font--size--sm) !important;
149149
}
150+
}
150151

152+
.pf-m-compact {
151153
.pf-chatbot__message-bar-actions {
152-
padding-block-start: var(--pf-t--global--spacer--md);
153-
padding-block-end: var(--pf-t--global--spacer--md);
154+
padding-block-start: var(--pf-t--global--spacer--sm);
155+
padding-block-end: var(--pf-t--global--spacer--sm);
154156
}
155157
}
156158

159+
// ============================================================================
160+
// Multiline textarea styles (2+ lines)
161+
// ============================================================================
162+
.pf-chatbot__message-bar.pf-m-multiline {
163+
border-radius: calc(var(--pf-t--global--border--radius--small) * 2);
164+
}
165+
157166
// ============================================================================
158167
// High contrast styles
159168
// ============================================================================

packages/module/src/MessageBar/MessageBar.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
161161
const [isListeningMessage, setIsListeningMessage] = useState<boolean>(false);
162162
const [hasSentMessage, setHasSentMessage] = useState(false);
163163
const [isComposing, setIsComposing] = useState(false);
164+
const [isMultiline, setIsMultiline] = useState(false);
164165
const inputRef = useRef<HTMLTextAreaElement>(null);
165166
const textareaRef = (innerRef as React.RefObject<HTMLTextAreaElement>) ?? inputRef;
166167
const attachButtonRef = useRef<HTMLButtonElement>(null);
@@ -209,6 +210,19 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
209210
return lines > 2;
210211
};
211212

213+
const checkIfMultiline = useCallback(
214+
(field: HTMLTextAreaElement) => {
215+
const parent = field.parentElement;
216+
const grandparent = parent?.parentElement;
217+
if (grandparent) {
218+
const containerHeight = grandparent.offsetHeight;
219+
const threshold = isCompact ? 56 : 70;
220+
setIsMultiline(containerHeight > threshold);
221+
}
222+
},
223+
[isCompact]
224+
);
225+
212226
const setAutoWidth = useCallback((field: HTMLTextAreaElement) => {
213227
const parent = field.parentElement;
214228
if (parent) {
@@ -263,12 +277,14 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
263277
if (field) {
264278
if (field.value === '') {
265279
setInitialLineHeight(field);
280+
setIsMultiline(false);
266281
} else {
267282
setAutoHeight(field);
268283
setAutoWidth(field);
284+
checkIfMultiline(field);
269285
}
270286
}
271-
}, [displayMode, message, setAutoWidth]);
287+
}, [displayMode, message, setAutoWidth, checkIfMultiline]);
272288

273289
useEffect(() => {
274290
const field = textareaRef.current;
@@ -284,13 +300,15 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
284300
if (textareaRef.current) {
285301
if (event.target.value === '') {
286302
setInitialLineHeight(textareaRef.current);
303+
setIsMultiline(false);
287304
} else {
288305
setAutoHeight(textareaRef.current);
306+
checkIfMultiline(textareaRef.current);
289307
}
290308
}
291309
setMessage(event.target.value);
292310
},
293-
[onChange]
311+
[onChange, checkIfMultiline]
294312
);
295313

296314
// Handle sending message
@@ -453,7 +471,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
453471
return (
454472
<AttachMenu
455473
toggle={(toggleRef) => (
456-
<div ref={toggleRef} className={`pf-chatbot__message-bar ${className ?? ''}`}>
474+
<div ref={toggleRef} className={css('pf-chatbot__message-bar', isMultiline && 'pf-m-multiline', className)}>
457475
{messageBarContents}
458476
</div>
459477
)}
@@ -481,6 +499,7 @@ export const MessageBarBase: FunctionComponent<MessageBarProps> = ({
481499
isPrimary && 'pf-m-primary',
482500
hasAiIndicator && 'pf-v6-m-ai-indicator',
483501
isThinking && 'pf-v6-m-thinking',
502+
isMultiline && 'pf-m-multiline',
484503
className
485504
)}
486505
>

packages/module/src/MessageBar/MicrophoneButton.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@
5353
.pf-v6-c-button.pf-chatbot__button--microphone.pf-m-compact {
5454
width: 1.5rem;
5555
height: 1.5rem;
56-
padding: var(--pf-t--global--spacer--sm);
5756
align-items: center;
5857
}

packages/module/src/MessageBar/SendButton.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@
5858
.pf-v6-c-button.pf-chatbot__button--send.pf-m-compact {
5959
width: 1.5rem;
6060
height: 1.5rem;
61-
padding: var(--pf-t--global--spacer--sm);
6261
align-items: center;
6362
}

packages/module/src/MessageBar/StopButton.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@
4141
.pf-v6-c-button.pf-chatbot__button--stop.pf-m-compact {
4242
width: 1.5rem;
4343
height: 1.5rem;
44-
padding: var(--pf-t--global--spacer--sm);
4544
align-items: center;
4645
}

0 commit comments

Comments
 (0)