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

Grid API for conditional selectability #4956

Closed
1 of 14 tasks
rolfsmeds opened this issue Jan 24, 2024 · 6 comments
Closed
1 of 14 tasks

Grid API for conditional selectability #4956

rolfsmeds opened this issue Jan 24, 2024 · 6 comments
Labels
acceptance criteria used for the acceptance criteria checklist DS Design System feature (e.g. component)

Comments

@rolfsmeds
Copy link
Collaborator

rolfsmeds commented Jan 24, 2024

Description

An API in Grid for dynamically setting whether the user can select or deselect an item (row) in the Grid.
(Similar e.g. to PartNameGenerator and TooltipGenerator)

Use cases

As a user
I want to be able to select only those items that should be selectable
So that I can select valid items

Acceptance criteria

  • Java API for setting a selectability function setItemSelectable(SerializableFunction<T,boolean> selectabilityFunction)
  • WC API isItemSelectable callback function
  • Items for which the function returns false should be rendered with a disabled checkbox in multiselect row, not propagate a selection event, and the server should ignore selections on those items.
  • Programmatically selecting or deselecting items is not affected by this
  • Drag-select should skip unselectable items
  • Part names should reflect non-selectability: nonselectable-row and nonselectable-row-cell
  • Modify clientside single-select example to call the function to determine selectability.

(precise naming of API is open for suggestions, the above is just a proposal)

General criteria

  • APIs reviewed

  • Performance (let's test!)

  • UX/DX tests in Alpha

  • Documentation: (to be added to Grid docs)

  • How to test?

  • Limitations:

Security

  • Security implications have been taken into account (elaborate or link to product security requirement specification if there are implications)
@rolfsmeds rolfsmeds added acceptance criteria used for the acceptance criteria checklist DS Design System feature (e.g. component) draft The acceptance criteria that is still WIP labels Jan 24, 2024
@knoobie
Copy link
Contributor

knoobie commented Jan 24, 2024

Items for which the function returns false should be rendered with a disabled checkbox in multiselect row, and simply not allow selection

Should there be a tooltip / reason why the checkbox is disabled or should the checkbox not be rendered at all?

@rolfsmeds
Copy link
Collaborator Author

Should there be a tooltip / reason why the checkbox is disabled or should the checkbox not be rendered at all?

I would expect that, in most use cases, the reasons for some items being disabled from selection would be fairly obvious from the context in which selection happens, and, even if it's not, the reason would probably be the same for all items, in which case a text somewhere adjacent to the Grid would serve better than per-item tooltips.

We discussed whether the checkbox should be disabled or entirely hidden, but my hunch is that it's better to keep it visible but disabled so that users see that there is selection in the Grid, even if all none of the items currently in the viewport can be selected. There are also use cases where some items can be selected and disabled, i.e. un-deselectable, in which case we definitely need to show the checkbox.

@yuriy-fix yuriy-fix removed the draft The acceptance criteria that is still WIP label Feb 13, 2024
@github-project-automation github-project-automation bot moved this to Under consideration in Roadmap Feb 13, 2024
@AndreGlauserAtWork
Copy link

Should there be a tooltip / reason why the checkbox is disabled or should the checkbox not be rendered at all?

I would expect that, in most use cases, the reasons for some items being disabled from selection would be fairly obvious from the context in which selection happens, and, even if it's not, the reason would probably be the same for all items, in which case a

If there were a list of people in a grid, where users that did not have an email address or phone number could not be selected. Of course, these users could be filtered out from the grid, but lets assume that all users are in the grid. I would need to show why this role could not be selected. Having a note or footer text which states "users with no phone number or email can not be selected" is possible but it seems more user friendly to me that a tooltip for that unselectable row would be clearer to the user? The reason could be more complex per row as a calculation from the data for example, then the tooltip would have a more complex description also.

@rolfsmeds
Copy link
Collaborator Author

I still think it should in most cases be obvious from the context why some items are not selectable. Let's say, e.g. that in your example you're selecting people to contact. You'd probably show the email and the phone number in the Grid, in addition to the person's name. The opposite – not showing those columns, and relying instead on a tooltip – would be pretty bad UX.

And even in cases where you do need to explicitly explain why some items cannot be selected, I still think it would be better to have an always-visible message for it, rather than relying on users hovering the selection column (and pausing for a bit) to see it.

I'm not saying that there could not be cases where the reason varies in complex ways for each item, and you still want to show all of those items in the Grid, but I struggle to imagine such a use case, and I'm still skeptical of a tooltip being a good solution for it.

And if you really want to have a tooltip, you could use the regular Grid tooltip feature.

So for now I'm keeping that outside of the scope of this feature. You could open a separate feature request ticket for a selection-column-specific tooltip generator feature, though. If it seems like a lot of people want it, we could add it later.

@knoobie
Copy link
Contributor

knoobie commented Oct 22, 2024

Vote for: Use this feature request / question as example in the docs to show that it is possible with the regular tooltip feature of the Grid. That also comes with the added benefit that the tooltip is visible on the whole row - and not just the single column / disabled checkbox.

@AndreGlauserAtWork
Copy link

@rolfsmeds I have a use case with a list of transactions in the grid and there are several ways that the transaction can be disabled for selection and the transaction data is used to calculate it differently for each row. So, in this case a reason for each row has to be on the row as a tooltip. I was not saying that a tooltip should be part of the task, just that the use case is not so uncommon.

Until this new API is available: I use the partNameGenerator to style the row differently, and a tooltip for the whole row to explain why that row is disabled. The first-column-cell gets disabled in CSS using the various partNames.
Maybe not the best UX for this, but I could not think of a better way yet.

@rolfsmeds rolfsmeds changed the title Grid API for dynamically setting items to be selectable Grid API for conditional selectability Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acceptance criteria used for the acceptance criteria checklist DS Design System feature (e.g. component)
Projects
Status: December 2024 (24.6) - Released
Development

No branches or pull requests

4 participants