vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
616 stars 167 forks source link

@PageTitle/HasDynamicTitle for application #6807

Open stefanuebe opened 4 years ago

stefanuebe commented 4 years ago

Currently @PageTitle and HasDynamicTitle are only interpreted when used in a routed component. That is useful for applications, where each view should show a separate title.

But there are other use cases where this behavior is not useful:

(The second case can be achieved by using afterNavigation and Page.setTitle, but that approach has the disadvantage, that the page might be built already and the title is set with some lag, when the components take long to load - with using HasDynamicTitle it could be loaded prior to the page itself).

The request is to let those title configs also be usable on route layouts.

For the case, that a nested route layout or a route itself also defines a title, the most specific should always win (route > inner route layout > outer route layout).

pleku commented 4 years ago

How about writing the application logic for handling the title in your own interface that extends HasDynamicTitle, and then making all your own views implement that interface, optionally overriding things ?

stefanuebe commented 4 years ago

I would consider that as a workaround - in the end its the same as having a String constant somewhere and let every view use that inside the @PageTitle.

It is surely possible to overcome the basic problem by either using your approach or the one with the constant String, but in the end it's unneeded dev overhead, especially for such a "simple" feature, that HTML knows for decades now.

(I personally do not consider this a very critical request but rather more a nice to have, since it appears to be a basic feature that I guess many devs would expect from a UI framework to have :) )

Frettman commented 2 years ago

I came here looking for a way to inherit the page title from a parent layout. It seems setTitle(...) during afterNavigation no longer works (see #13871). @PageTitle on the AppShellConfigurator works, but that's not dynamic / localizable; letting it implement HasDynamicTitle doesn't seem to do anything.

stefanuebe commented 1 year ago

As it seems HasDynamicTitle does not work for layouts neither?