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

Disabled DragValue still resets focus when using tab-navigation #5507

Open
KonaeAkira opened this issue Dec 20, 2024 · 0 comments
Open

Disabled DragValue still resets focus when using tab-navigation #5507

KonaeAkira opened this issue Dec 20, 2024 · 0 comments
Labels
bug Something is broken

Comments

@KonaeAkira
Copy link

KonaeAkira commented Dec 20, 2024

Related issue: #5359

It seems like #5370 doesn't fully fix the issue, because a disabled DragValue will still eat the focus, resulting in nothing being focused when using TAB to navigate.

I've made the following test case to verify it:

// crates/egui_kittest/tests/regression_tests.rs

#[test]
pub fn focus_should_skip_over_disabled_drag_values() {
    let mut value_1: u16 = 1;
    let mut value_2: u16 = 2;
    let mut value_3: u16 = 3;

    let mut harness = Harness::new_ui(|ui| {
        ui.add(DragValue::new(&mut value_1));
        ui.add_enabled(false, DragValue::new(&mut value_2));
        ui.add(DragValue::new(&mut value_3));
    });

    harness.press_key(egui::Key::Tab);
    harness.run();

    let drag_value_1 = harness.get_by(|node| node.numeric_value() == Some(1.0));
    assert!(drag_value_1.is_focused());

    harness.press_key(egui::Key::Tab);
    harness.run();

    let drag_value_3 = harness.get_by(|node| node.numeric_value() == Some(3.0));
    assert!(drag_value_3.is_focused()); // assertion failed: drag_value_3.is_focused()
}
@KonaeAkira KonaeAkira added the bug Something is broken label Dec 20, 2024
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

No branches or pull requests

1 participant