Initial render has incorrect layout size/offset in Ratzilla WebRenderer
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Start at the main entry point around DomBackend::new, Terminal::new, and terminal.draw_web, then reproduce the first-load and refresh behavior in the stated Chrome, Trunk, and wasm32 environment. Inspect the initial terminal size calculation and WebRenderer initialization timing; done means the first render has the same layout and size as later renders without an unexpected scrollbar.
Written by the indexing model from the issue text.
Description
Description
When running a Ratzilla application in the browser, the first page load sometimes renders with an incorrect layout.
Symptoms:
- UI is incorrectly scaled or shifted.
- Unexpected browser scrollbar appears
- Layout becomes correct after refreshing the page
The issue only happens on the first load(or refresh via ctrl+shift+R).
Environment
- OS: Windows 11
- Browser: Chrome (latest)
- Target:
wasm32-unknown-unknown - Build tool: Trunk
Versions:
[dependencies]
ratatui = { version = "0.30.1", default-features = false, features=['std'] }
color-eyre = "0.6.5"
ratzilla = "0.3.1"
Code
use std::{io, rc::Rc};
use ratatui::{
layout::{Alignment, Constraint, Layout, VerticalAlignment},
style::{Color, Stylize},
widgets::{Block, BorderType, Paragraph},
Frame, Terminal,
};
use ratzilla::{DomBackend, WebRenderer};
fn main() -> io::Result<()> {
let backend = DomBackend::new()?;
let terminal = Terminal::new(backend)?;
let state = Rc::new(App::default());
let render_state = Rc::clone(&state);
terminal.draw_web(move |frame| {
render_state.render(frame);
});
Ok(())
}
#[derive(Default)]
struct App {}
impl App {
fn render(&self, frame: &mut Frame) {
let [top, bottom] =
Layout::vertical([Constraint::Percentage(60), Constraint::Percentage(40)])
.areas(frame.area());
// Splicing top
let [_, art_area] =
Layout::vertical([Constraint::Fill(1), Constraint::Length(8)]).areas(top);
let [_, tab_area, _] = Layout::vertical([
Constraint::Fill(1),
Constraint::Length(2),
Constraint::Fill(1),
])
.areas(bottom);
let block = Block::new();
let text = format!(
r#"
_ _ _ _ __ __ _ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_)
"#
);
let paragraph = Paragraph::new(text)
.block(block)
.fg(Color::White)
.bg(Color::Black)
.centered();
let block_2 = Block::new()
.title("WORLD • HELLO • ko-KR • zh-CN • en-US • Backend • CLI")
.title_alignment(Alignment::Center);
frame.render_widget(paragraph, art_area);
frame.render_widget(block_2, bottom);
}
}
Expected behavior
The first render should have the same layout and size as subsequent renders.
Actual behavior
On the first load:
- Layout size appears incorrect
- Widgets may be offset
- Scrollbar may appear unexpectedly
After refreshing:
- The layout renders correctly.
Refresh via ctrl+shift+R:
- Same issue as the first load
Tried solutions
- Added overflow: hidden to html/body.
- Changed viewport sizing from 100vh to 100dvh.
- Removed external font loading to avoid layout shift.
- Triggered browser resize events manually after WASM initialization.
None of these fixed the issue.
Question
Could this be related to the initial terminal size calculation or WebRenderer initialization timing?
Is there a recommended way to force Ratzilla to recalculate the terminal size after the initial DOM layout is completed?
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ratatui/ratzilla
-
DOM backend loses input callbacks after resizePossibly taken @thelastbackspace claimed this 24 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in ratatui/ratzilla
Similar issues
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Possibly taken @ealwanlee claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
psmux/psmux-plugins#47 ·
-
Link Checker ReportOpenautomated issue report
Difficulty 1/5 Under an hour Newbie friendliness 76/100
ratatui/awesome-ratatui#598 ·
Maintainers usually reply within 1 day
-
area:core priority:high status:ready type:security
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
release
Difficulty 1/5 Under an hour Newbie friendliness 75/100
github/gh-aw-mcpg#17603 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day