Skip to content

egui_extras::Table doesn't behave properly when inside of a ScrollArea #3670

@abey79

Description

@abey79

Bug

egui_table_bug.mp4

Repro

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use eframe::egui;
use eframe::egui::ScrollArea;

fn main() -> Result<(), eframe::Error> {
    env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
        ..Default::default()
    };
    eframe::run_native(
        "My egui App",
        options,
        Box::new(|cc| {
            // This gives us image support:
            egui_extras::install_image_loaders(&cc.egui_ctx);

            Box::<MyApp>::default()
        }),
    )
}

#[derive(Default)]
struct MyApp;

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ScrollArea::both().show(ui, |ui| {
                egui_extras::TableBuilder::new(ui)
                    .auto_shrink([false, true])
                    .vscroll(false)
                    .columns(egui_extras::Column::exact(50.0), 2)
                    .header(18.0, |mut header| {
                        header.col(|ui| {
                            ui.label("Col1");
                        });
                        header.col(|ui| {
                            ui.label("col2");
                        });
                    })
                    .body(|body| {
                        body.rows(18.0, 100, |idx, mut row| {
                            row.col(|ui| {
                                ui.label(format!("R{}C1", idx));
                            });
                            row.col(|ui| {
                                ui.label(format!("R{}C2", idx));
                            });
                        });
                    });
            });
        });
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokenegui_extrasrerunDesired for Rerun.io

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions