vaadin / starters

Issue repository for all the starter projects in https://vaadin.com/start
3 stars 0 forks source link

Generated Views in Starter App should mention RouterLink #56

Open dmitrilc opened 2 years ago

dmitrilc commented 2 years ago

The classes generated at https://start.vaadin.com/app should contain a short comment in their code to remind developers that usage of RouterLink is needed for the route to show up in the Drawer.

It was a little frustrating after adding custom Views in code only for them to not show up in the Drawer. My expectations were that if I added a custom View, then it should automatically show up in the Drawer.

It took me about 1 hour and 30 minutes of debugging and going back to the tutorial at https://vaadin.com/docs/latest/flow/tutorial/navigation-and-layouts/#defining-view-routes as well as going deep into https://vaadin.com/docs/latest/flow/routing/navigation to find the answer.

The generated MainLayout class contains a lot of custom classes as well, so it took some time to digest.

I have three suggestions to improve the user experience for Vaadin beginners:

  1. Add a comment in generated Views in the starter project to mention that this class only defines a route, accessible directly from the browser URL. The developer will have to write some more boilerplate if they want to add this route to the Drawer.
  2. Same as number 1, but as JavaDoc instead of comments.
  3. The generated Views should display at run time that they are visible in the Drawer only because they have been programmatically added in MainLayout class. Something like:
//...in HelloWorldView.java constructor
text = new TextArea()
text.setText(howToAddMeToDrawerHint)
add(text)
Artur- commented 2 years ago

Hey, thanks for the input!

Do you think it would be even more beneficial if we changed it to match your initial expectations to that the menu would be auto-generated based on the routes you define and then you would instead opt-out of that if you want to define the menu by hand?