Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableBuilder id_salt does not result in unique scroll areas #5281

Open
jwhear opened this issue Oct 17, 2024 · 0 comments · May be fixed by #5282
Open

TableBuilder id_salt does not result in unique scroll areas #5281

jwhear opened this issue Oct 17, 2024 · 0 comments · May be fixed by #5282
Labels
bug Something is broken

Comments

@jwhear
Copy link

jwhear commented Oct 17, 2024

Describe the bug
TableBuilder.id_salt does not result in unique table scroll areas.

To Reproduce

use eframe::egui;
use egui_extras::{Column, TableBuilder};

fn main() -> eframe::Result {
    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(|_| Ok(Box::new(MyApp {}))))
}

struct MyApp {}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.horizontal(|ui| {
                let mut table = |salt| {
                    //ui.push_id(salt, |ui| {
                    TableBuilder::new(ui)
                        .id_salt(salt)
                        .column(Column::initial(60.0))
                        .vscroll(true)
                        .body(|body| {
                            body.rows(30.0, 100, |mut row| {
                                let index = row.index();
                                row.col(|ui| {
                                    ui.label(format!("{index}"));
                                });
                            });
                        })
                    //});
                };

                table("left");
                table("right");
            });
        });
    }
}

Despite setting different ID salts, a warning appears (reused scroll area id) and the tables scroll together.

Uncommenting the push_id call results in correct behavior.

Expected behavior
Using id_salt with distinct salts should result in independently scrolling tables.

Screenshots
capture

Desktop (please complete the following information):

  • OS: Linux, Fedora 40
  • Version: 0.29.0, 0.29.1 and master
@jwhear jwhear added the bug Something is broken label Oct 17, 2024
jwhear added a commit to jwhear/egui that referenced this issue Oct 17, 2024
The salt is based on the table's `state_id`.
Fixes emilk#5281
@jwhear jwhear linked a pull request Oct 17, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant