canonical / react-components

A set of components based on Vanilla Framework
https://canonical.github.io/react-components
101 stars 57 forks source link

Focus on confirm in ConfirmationModal #945

Closed huwshimi closed 1 month ago

huwshimi commented 1 year ago

It would be nice if there was a way to set the focus on the confirm button when opening the modal so that users can press enter to confirm.

This should probably only happen if the confirm is positive (maybe it should focus on cancel if the action is negative). Here's how we do something similar in Juju Dashboard (though it only happens for "neutral" actions): https://github.com/canonical/juju-dashboard/blob/main/src/components/ConfirmationModal/ConfirmationModal.tsx#L23.

bartaz commented 11 months ago

As discussed in the PR from accessibility point of view if the action is destructible (or at least hard to revert) modal should not focus on the action button, but rather cancel/close (which happens right now I believe).

Confirmation modal by definition is meant to be used to confirm actions that may have irreversible consequences.

If action is neutral, or easy to undo, why have confirmation modal at all? Can't it be triggered immediately (instead of opening the modal)?

bartaz commented 1 month ago

Triage: closing this for now, as it doesn't seem to be needed as requested.

If we want to consider it as a feature, this likely needs to be raised with UX.