fix(ui): prevent double vertical scrollbars in latex math rendering#2967
fix(ui): prevent double vertical scrollbars in latex math rendering#2967Siddhu2k04 wants to merge 1 commit into
Conversation
Co-Authored-By: Antigravity <noreply@google.com>
|
Hi @asvishnyakov and @sandangel, I've submitted a fix for #2949 and verified that it resolves the duplicate vertical scrollbar issue when LaTeX rendering is enabled. Could you please review the PR when you have a chance? Any feedback is appreciated. Thanks! 🚀 |
|
This PR is stale because it has been open for 14 days with no activity. |
|
Please someone to merge this PR? We need this issue to be fixed in the production. Thanks in advance. |
|
The CSS approach in this PR (setting After digging into The fix that worked for us was changing the outer wrapper from // frontend/src/components/chat/ScrollContainer.tsx, line 196
// Before
<div className="relative flex flex-col flex-grow overflow-y-auto">
// After
<div className="relative flex flex-col flex-grow overflow-hidden">This makes the inner Since we couldn't patch the source directly, we applied this as a JS workaround via document.querySelectorAll('div.relative.flex-grow.overflow-y-auto').forEach(wrapper => {
if (wrapper.querySelector(':scope > div.overflow-y-auto')) {
wrapper.style.overflowY = 'hidden';
}
});Would suggest updating this PR to target ScrollContainer.tsx instead of the KaTeX elements. |
Fix duplicate vertical scrollbar when LaTeX rendering is enabled
Summary
This PR fixes an issue where enabling
latex=trueinconfig.tomlcould cause two vertical scrollbars to appear in the chat UI when rendering LaTeX content.Root Cause
The chat interface already provides a scrollable container for messages. When LaTeX content is rendered, the math wrapper may introduce additional overflow behavior, creating a nested scroll container and resulting in duplicate vertical scrollbars.
Changes
Removed unnecessary vertical overflow handling from LaTeX rendering containers.
Restricted LaTeX elements to horizontal scrolling only when needed.
Ensured the main chat container remains the sole vertical scroll region.
Preserved existing LaTeX rendering behavior and layout.
Before
latex=trueenabled.Sending multiple messages containing LaTeX equations eventually displays two vertical scrollbars.
After
Only one vertical scrollbar is displayed.
LaTeX equations render correctly.
Normal chat scrolling behavior remains unchanged.
Testing
Reproduction Steps
Enable
latex=trueinconfig.toml.Run the following application:
Start Chainlit.
Send messages multiple times until the chat becomes scrollable.
Results
References
Fixes UI displays two vertical scrollbars with enabled latex rendering #2949
Related to UI displays two vertical scrollbars whenever a custom element is rendered #2003