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

TabSheet fires SelectedChangeEvent before the tab component is added #6717

Open
schwarzwald opened this issue Oct 11, 2024 · 0 comments
Open

Comments

@schwarzwald
Copy link

schwarzwald commented Oct 11, 2024

Description of the bug

When a tab is added to the TabSheet and if it's the first tab, the tab sheet may automatically select this tab. This triggers the SelectedChangeEvent, but it happens before the tab component is added to the internal tabToContent map. If we want to access the selected component when the tab selection listener is notified, the tab sheet returns null.

Expected behavior

The SelectedChangeEvent should be fired after the tab component is internally registered, so that we can access is when the listener is notified.

Minimal reproducible example

var tabsheet = new TabSheet();
tabsheet.addSelectedTabChangeListener(e -> {
  if (e.getSelectedTab() != null) {
    Objects.requireNonNull(tabsheet.getComponent(e.getSelectedTab()));
  }
});
tabsheet.addTab("tab", new Div());

Versions

  • Vaadin / Flow version: 24.5.0 (but may occur also on earlier versions)
@tepi tepi transferred this issue from vaadin/flow Oct 11, 2024
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

2 participants