Skip to content

Commit f1029ff

Browse files
authored
improve: Resolve overlapping "Ask" button and improve input field text visibility (#165)
* improve: enhance input field layout for better text visibility - Add right padding (pr-32) to input field to ensure text visibility - Maintain button position while providing adequate space for text content - Improve user experience for long text input * improve: optimize button width measurement - Replace ResizeObserver with direct width measurement - Update width calculation on button text and loading state changes - Simplify implementation while maintaining functionality
1 parent 77b7488 commit f1029ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/Ask.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,17 @@ const Ask: React.FC<AskProps> = ({
604604
}
605605
};
606606

607+
const [buttonWidth, setButtonWidth] = useState(0);
608+
const buttonRef = useRef<HTMLButtonElement>(null);
609+
610+
// Measure button width and update state
611+
useEffect(() => {
612+
if (buttonRef.current) {
613+
const width = buttonRef.current.offsetWidth;
614+
setButtonWidth(width);
615+
}
616+
}, [messages.ask?.askButton, isLoading]);
617+
607618
return (
608619
<div>
609620
<div className="p-4">
@@ -631,9 +642,11 @@ const Ask: React.FC<AskProps> = ({
631642
onChange={(e) => setQuestion(e.target.value)}
632643
placeholder={messages.ask?.placeholder || 'What would you like to know about this codebase?'}
633644
className="block w-full rounded-md border border-[var(--border-color)] bg-[var(--input-bg)] text-[var(--foreground)] px-5 py-3.5 text-base shadow-sm focus:border-[var(--accent-primary)] focus:ring-2 focus:ring-[var(--accent-primary)]/30 focus:outline-none transition-all"
645+
style={{ paddingRight: `${buttonWidth + 24}px` }}
634646
disabled={isLoading}
635647
/>
636648
<button
649+
ref={buttonRef}
637650
type="submit"
638651
disabled={isLoading || !question.trim()}
639652
className={`absolute right-3 top-1/2 transform -translate-y-1/2 px-4 py-2 rounded-md font-medium text-sm ${

0 commit comments

Comments
 (0)