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

Grid completely ignores tabIndex in editor fields / Reordering columns does not update focus order for editor fields #7401

Open
hoshie82 opened this issue May 10, 2024 · 2 comments

Comments

@hoshie82
Copy link

hoshie82 commented May 10, 2024

Description of the bug

If you're setting the tabIndex for a field in a grid manually, it is completely ignored.

If you're reordering columns and focussing the fields again, the order for moving through the cells with tab is not updated. Only if the grid is detached and attached again, the order after reordering works

Expected behavior

The tabIndex was just a attempt for a workaround.. Reordering is more important for me...

If you reorder the columns, the focus order with tab should be updated, so focussing the first column, pressing tab should focus the second column.

Minimal reproducible example

  • click on the row and focus column "s3" and press tab
  • column s4 is focussed
  • move column s3 to first position
  • focus s3 again and press tab
  • column s4 is focussed again

expected:

  • after reordering column s1 (right to s3) should be focussed.
  private Component buildTestGrid() {
        Grid<DataObject> grid = new Grid<>();
        Editor<DataObject> editor = grid.getEditor();
        editor.setBinder(new Binder<>());
        editor.setBuffered(false);
        grid.addItemClickListener(e -> {
            if (!editor.isOpen()) {
                editor.editItem(e.getItem());
            }
        });
        grid.setColumnReorderingAllowed(true);
        new ColumnTabIndex("s1", DataObject::getS1, DataObject::setS1, 5).addToGrid(grid);
        new ColumnTabIndex("s2", DataObject::getS2, DataObject::setS2, 4).addToGrid(grid);
        new ColumnTabIndex("s3", DataObject::getS3, DataObject::setS3, 3).addToGrid(grid);
        new ColumnTabIndex("s4", DataObject::getS4, DataObject::setS4, 2).addToGrid(grid);
        new ColumnTabIndex("s5", DataObject::getS5, DataObject::setS5, 1).addToGrid(grid);

        grid.setItems(new DataObject("1", "2", "3", "4", "5"));
        return grid;
    }

    @Data
    @RequiredArgsConstructor
    private static class ColumnTabIndex {
        private final String key;
        private final ValueProvider<DataObject, String> getter;
        private final Setter<DataObject, String> setter;
        private final int tabIndex;

        void addToGrid(Grid<DataObject> grid) {
            TextField tf = new TextField();
            tf.setTabIndex(tabIndex);
            Binder<DataObject> b = grid.getEditor().getBinder();
            b.forField(tf).bind(getter, setter);
            grid.addColumn(getter).setKey(key).setHeader(key).setEditorComponent(tf);
        }
    }

    @Data
    @AllArgsConstructor
    private static class DataObject {
        private String s1;
        private String s2;
        private String s3;
        private String s4;
        private String s5;
    }

Versions

  • Vaadin / Flow version: 24.3.11
  • Java version: 21
  • OS version: windows 11
  • Browser: chrome/firefox
@TatuLund
Copy link
Contributor

TatuLund commented May 10, 2024

I think this is same as this one: #3275

@TatuLund TatuLund transferred this issue from vaadin/flow May 10, 2024
@hoshie82
Copy link
Author

hoshie82 commented May 10, 2024

@TatuLund looks similar for the tabindex-issue.. but this does not fix the problem with the reordering?!

This is caused by the cell handling within the row i think!? Solving 3275 would only provide a workaround?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants