Altinn / app-frontend-react

Altinn application React frontend
BSD 3-Clause "New" or "Revised" License
18 stars 31 forks source link

Text cells in grid component are not rendered in mobile viewport #1138

Open lassopicasso opened 1 year ago

lassopicasso commented 1 year ago

Description of the bug

Text cells are not rendered in the new grid component when it is displayed as a table in mobile viewport.

This happens because of nodesFromGrid is called in mobile viewport and it skips cells that contains text. See image below. A possible solution is to use paragraph components instead, but this is probably not an optimal solution since text cells works in desktop view?

image

Steps To Reproduce

  1. Create the new grid component with text-cells.
  2. Limit the width to less than 765px.
  3. The component acts as a table now and does not display the text cells.

Additional Information

Conversation with SSB about this: https://altinn.slack.com/archives/C02EVE4RU82/p1683103041485429

olemartinorg commented 1 year ago

Adding the ux label here, because we should rather think up "the way" to display a Grid component in a mobile-friendly way. In a sense, the Grid component is inherently incompatible with a mobile viewport, but all components used in a Grid must have accessibility information configured (such as title in their text resource bindings), so just displaying the components themselves (without the text cells) should give the user all the information they need.

Look at the screenshots in the docs:

In the Grid/table, the first component is displayed on the right of the "Boliglån" text cell, and underneath the "Fordeling" header. We could perhaps display both "Boliglån" and "Fordeling" as stand-alone paragraphs somewhere over the component, but that does not convey the information the user needs. In the mobile screenshot, the component itself has been given a title of "Prosentandel av gjeld i boliglån" which is also the text a screen-reader tool uses when the component is displayed in a Grid/table. In my opinion, that component label is sufficient (and should be sufficient), so showing the text cells containing "Fordeling" and "Boliglån" somewhere just adds noise in a mobile setting.

olemartinorg commented 1 year ago

I should mention that I found design sketches for a mobile table in #107, which might be highly relevant here:

https://user-images.githubusercontent.com/1464915/156745035-e494f2ea-c83b-40e0-8a0e-0c4a882955c5.mov

https://user-images.githubusercontent.com/1464915/156747467-31a4f3a2-9cb1-494d-94ad-0958fa3f621c.mov

We could possibly look into existing Grid usage and check if these suggestions will work out nicely for those apps, and implement a less naiive mobile mode. Take care to also make sure the mobile mode for Grid-rows-in-repeating-group-table works (see #1186).