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 internal tabs customization #5232

Open
gschrader opened this issue Jul 6, 2023 · 9 comments
Open

TabSheet internal tabs customization #5232

gschrader opened this issue Jul 6, 2023 · 9 comments
Labels
enhancement New feature or request vaadin-tabs

Comments

@gschrader
Copy link

gschrader commented Jul 6, 2023

Describe your motivation

I wanted to be able to set the tabs orientation to vertical.

Describe the solution you'd like

maybe add a method to allow to customize the tabs instance in case further methods become available:

In the class TabSheet:

    public void customizeTabs(Consumer<Tabs> tabsConsumer) {
        tabsConsumer.accept(tabs);
    }

my usage to set vertical orientation would be

            tabSheet.customizeTabs(tabs -> {
                tabs.setOrientation(Tabs.Orientation.VERTICAL);
            });

Describe alternatives you've considered

I'm using reflection for now 🤮:

            Field field = TabSheet.class.getDeclaredField("tabs");
            field.setAccessible(true);
            Tabs tabs = (Tabs) field.get(tabSheet);
            tabs.setOrientation(Tabs.Orientation.VERTICAL);

Additional context

No response

@yuriy-fix yuriy-fix added the enhancement New feature or request label Jul 12, 2023
@yuriy-fix
Copy link
Contributor

We could consider exposing Tabs directly as a getter.

@gschrader
Copy link
Author

Yeah a getter would work, I'm not sure why I didn't just propose that.

@TatuLund
Copy link
Contributor

There is an alternative TabSheet component in Directory which has a feature of vertical Tabs https://vaadin.com/directory/component/tabsheet

@gschrader
Copy link
Author

I would prefer to stick with the official component for easier upgrades down the road.

@yuriy-fix
Copy link
Contributor

Additional context: #5370

@tomivirkki
Copy link
Member

tomivirkki commented Aug 31, 2023

I'm not sure if exposing Tabs in TabSheet is a good idea. Giving the user full control over the internal component may lead to unexpected results.

For example, with the following TabSheet:

Screenshot 2023-08-31 at 12 03 02

var tabsheet = new TabSheet();
tabsheet.setPrefixComponent(new Span("Prefix"));
tabsheet.setSuffixComponent(new Span("Suffix"));
tabsheet.add("Tab one", new Span("Tab one content"));
tabsheet.add("Tab two", new Span("Tab two content"));
add(tabsheet);

If you try to make the Tabs vertical with tabsheet.getTabs().setOrientation(Orientation.VERTICAL); (as implemented by #5408) you'd end up with:

Screenshot 2023-08-31 at 12 03 17

...which is probably not what you wanted here.

Vertical TabSheet should probably look more like this (needs better design of course):

Screenshot 2023-08-31 at 12 08 33

@gschrader
Copy link
Author

@tomivirkki you're right, I knew something didn't look quite right but it took your screenshots for me to realize. I have since gone with a different layout so I'm not sure what you want to do with this open issue.

@Avec112
Copy link

Avec112 commented Feb 27, 2024

I also would like to see TabSheet with vertical orientation. Like gschrader I also do not want to install components from Directory and not being part of Vaadin Flow.

@knoobie
Copy link
Contributor

knoobie commented Apr 4, 2024

...which is probably not what you wanted here.

Easy workaround:

vaadin-tabsheet {
  flex-direction: row;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vaadin-tabs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants