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

Text cell with help text in grid #1286

Merged
merged 10 commits into from
Jul 4, 2023

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Jun 27, 2023

Description

Two new configuration options have been introduced for grid cells:

  1. In addition to the text prop, the current text cell now also supports the help prop, which allows to include help text along with the text prop.
  2. A new type of cell has been added, which functions similarly to the text cell, but instead refers to text resources from a component. It uses the property labelFrom with the corresponding component ID. In the referenced component, you can access the title (which serves as the label for the component), description, and help to provide help text.

Example 1:

            "cells": [
              { "text": "laan-bolig", "help": "Dette er en hjelpetekst til laan-bolig" },
              ...
            ]

Example 2:

            "cells": [
              { "labelFrom": "<component-id>"},
              ...
            ]

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
  • Changes/additions to component properties
    • Changes are reflected in both src/layout/layout.d.ts and layout.schema.v1.json, and these are all backwards-compatible
    • No changes made
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@lassopicasso lassopicasso linked an issue Jun 27, 2023 that may be closed by this pull request
@lassopicasso lassopicasso added kind/user-story Used for issues that describes functionality for our users. kind/feature-request New feature or request and removed kind/user-story Used for issues that describes functionality for our users. labels Jun 27, 2023
@lassopicasso lassopicasso marked this pull request as ready for review June 27, 2023 12:16
@lassopicasso lassopicasso self-assigned this Jun 27, 2023
@olemartinorg
Copy link
Contributor

Hmm. A few comments on this one:

  1. I don't think we need the logic for aria-describedby. Components in Grid are described by their own text resources, as they are required for mobile support. Meaning, the components in the table have everything they need for accessibility already. Also the description should come from the description text resource binding - help text is something else.
  2. We can't make the assumption that a text cell describes all components in the same row. It's entirely valid to have a row that is [text cell, component, text cell, component], and so making assumptions that the first text cell describes the last component is most likely false.
  3. The thing I remember we discussed was to avoid duplicating the help text by referencing a component (the other way around from what is done here). Meaning that you could for example implement a row like:
{
  "cells": [
    { "textFrom": "myComponent" },
    { "component": "myComponent" }
  ]
}

And such a configuration would fetch the texts (i.e. title, help and possibly also description) from the target component and put them in the text cell. That way you get most of the same effects of the aria-describedby feature added here, but also:

  • No need to add the text resource bindings twice (both on the component and in the text cell)
  • We can implement functionality to make the title/description/label to work as a label (i.e. clicking on it focuses the target field)

@lassopicasso
Copy link
Contributor Author

Understood, thanks for the feedback @olemartinorg ! 👍🙏

@olemartinorg olemartinorg marked this pull request as draft June 29, 2023 09:21
@lassopicasso lassopicasso marked this pull request as ready for review July 3, 2023 08:39
Copy link
Contributor

@olemartinorg olemartinorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! 🚀 Some very minor and optional nitpicks in the comments.

src/layout/Grid/GridComponent.tsx Outdated Show resolved Hide resolved
src/layout/Grid/GridComponent.tsx Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Jul 4, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

6.3% 6.3% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@olemartinorg olemartinorg added kind/product-feature Pull requests containing new features and removed kind/feature-request New feature or request labels Jul 4, 2023
@lassopicasso lassopicasso merged commit b622e35 into main Jul 4, 2023
@lassopicasso lassopicasso deleted the 1230-grid-component-helptext-in-text-cells branch July 4, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/product-feature Pull requests containing new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid component: Helptext in text cells
2 participants