Unexpected order of multiple views

Which tool versions are you using?

SDK: v13.7.0
Platform: v23.02.2
Python: v3.10
Isolation mode: venv

Current Behavior

When having multiple views in a step, the order of these views is determined based on the order they are implemented in the controller class. For example, the following code:

    visualization = Step(
        "Visualization",
        views=["first_tab", "second_tab", "third_tab"],
        previous_label="Previous step",
        next_label="Next step",
    )

will result in the following order of views:

image

just because ā€œthird_tabā€ is implemented first in the controller class, ā€œsecond_tabā€ next and ā€œfirst_tabā€ last like this:

    @GeoJSONView("Third tab", duration_guess=3)
    def third_tab(self, params, **kwargs) -> GeoJSONResult:
        ...

    @PlotlyView("Second tab", duration_guess=10)
    def second_tab(self, params, **kwargs) -> PlotlyResult:
        ...

    @PlotlyView("First tab", duration_guess=3)
    def first_tab(self, params, **kwargs) -> PlotlyResult:
        ...

If I change the order in the controller class, I can get the order I want to show in the application. This might work for one step, but imagine having multiple steps with multiple views. At some point it would become impossible to get the desired order for every step.

P.S. I havenā€™t checked this for a ā€œPageā€. I guess the behaviour would be simillar.

Expected Behavior

It seems more logical to me to actually see the order as given in the parametrization, so that:

        views=["first_tab", "second_tab", "third_tab"],

would result in:
image

Hi Sina,

Welcome to the community forum! Thanks for posting.

You make a valid point. And indeed in the case of pages the behaviour is the same.
This is however by design. It may seem more logical to base the view order on the list you entered in your parametrization, however we need to take into account the order of methods and the way they are used in the controller across the whole app.

Nonetheless I think it is an interesting discussion to have, we already have an internal issue discussing this topic so I will add your contribution to it. If any developments result from it I will update you about them here!

Since itā€™s by design (which we could reconsider), I relabeled as ā€˜feature requestā€™.

Hi Daniƫl,

Thank you for your quick response. Interesting that the order of methods is taken into account. Would it be possible to share why without going too much into details?

Anyway! Thanks and if there are any updates, I would gladly hear it from you!

Hi @Sina ,

Fair question. It is possible to have views without any Page / Step at all, which was the only way in the past. The order of the views can, in that case, only be based on the order in the Controller (without additional information). To keep the API consistent, this was kept the same when implementing a Page or Step. You must see the list of views merely as a list of inclusion (without order).

1 Like

This has been fixed in the latest platform release

That is great! I will check it out. Thanks for letting me know!