Skip to content

Enter key should be consistent for dialogues/modals? #3629

Closed

Description

@tierninho

Hitting enter on some of the dialogues/modals results in an action, while other nothing happens. There should be consistency.

For instance:

  • hit enter on the Install Command Line Tool... dialogue and the OK is triggered
  • hit enter after selecting a repo on the Clone Repo modal and the Clone is not triggered
  • hit enter on git lock dialogue and Close is not triggered

screen shot 2017-12-18 at 11 45 59 am

screen shot 2017-12-18 at 11 55 15 am

Build v1.0.12-beta0. mac

Activity

  1. added
    good first issue
    help wanted
    on Dec 18, 2017
  2. http-request commented on Dec 19, 2017

    @http-request
    Contributor

    @tierninho About Install Command Line Tool, If you click inside dialog and ok button has lost focus then enter is not triggered. Do you want to set focus on buttons by default (and lose trigger when button lost focus) or add keyPress handler to components?

  3. koenpunt commented on Jan 11, 2018

    @koenpunt
    Contributor

    Consistent Enter, but also a consistent Space would be nice; on macOS most dialogs with more than 1 action, have the primary action respond to Enter, and highlight the secondary option to respond to Space. By hitting Tab one could move the action for Space to another option.

    For example the empty trash confirmation dialog:

    image

    Primary action is blue, so can be chosen by hitting Enter, the cancel option is highlighted by a blue outline, which indicates it can be chosen by hitting Space.

    Then when I hit Tab once, it looks like this:

    image

    Now I can confirm with both Space and Enter.

  4. agisilaos commented on Feb 1, 2018

    @agisilaos
    Member

    Hey @iAmWillShepherd I started digging into this and I observed how the ok is triggered on the Install Command Line Tool... but when I try to follow the same pattern to the clone repo modal I really hit a wall. Let me explain.

    In the command line tool modal the dialogue with the Ok button is triggered because of this line of code:

    onSubmit={this.props.onDismissed}

    But when I try to do something simillar for the Clone Repo modal, the "on Submit" line of code looks like that:

    I tried to create a 2nd onSubmit but that was a mistake and got an error from it. Any ideas how should I add the onSubmit={this.props.onDismissed} in the clone repo modal?

    I want to continue and work on the rest of the modals in this issue but this is an intro question that I have regarding this issue. Thanks in advance.

    P.s Also I would love to know if my approach finding what needs to be fixed and how is the "correct" one or if I need to think about it differently.

  5. iAmWillShepherd commented on Mar 5, 2018

    @iAmWillShepherd
    Contributor

    @agisilaos, so sorry I'm getting to this so late. I think the issue is about consistency with actions. In your second example, the correct action to take on enter is to Clone, not dismiss the dialog. Maybe we can make esc the default key to close a modal?

  6. agisilaos commented on Mar 6, 2018

    @agisilaos
    Member

    Makes total sense, thank you for getting back to me with that info. Will work on that and I will let you know if I have any questions etc. @iAmWillShepherd!

  7. iAmWillShepherd commented on Mar 6, 2018

    @iAmWillShepherd
    Contributor

    @agisilaos, I'm sure you know by now, but could you add Fixes #3629 at the top of your PR body when you open it?

  8. agisilaos commented on Mar 13, 2018

    @agisilaos
    Member

    @iAmWillShepherd The current issue that we have here is that when you press enter after you selected a repo to clone nothing happens. If you press esc the dialog dismiss just fine. I'm trying to achieve what @tierninho mentioned in the issue description:

    hit enter after selecting a repo on the Clone Repo modal and the Clone is not triggered.

    How I make the clone to be triggered after tapping enter? That's why I followed up with my question above. Sorry if that didn't make sense in the first place.

  9. niik commented on Mar 19, 2018

    @niik
    Member

    I would like to alter the focus of this issue to clearly defining what the expected behavior is before we move on to implementation. @koenpunt shows some examples where the dialog doesn't contain any input fields and it's hard not to agree with the behavior outlined there but I'd like to see some references to macOS and Windows interface guidelines so that we can accurately capture the expected behavior on both platforms.

    Is this a matter of automatically focusing the correct button when there's not input fields in the dialog or is the expected behavior that Enter should automatically focus and execute the primary non-destructive action regardless of where focus lies inside of the dialog?

    I'm going to remove the good-first-issue as issues labeled as such should have clear steps and well-defined goals for success but I'm keeping the help-wanted to get some input on the UX.

    cc @donokuda @ampinsk

  10. removed
    good first issue
    on Mar 19, 2018
  11. gingerbeardman commented on Mar 19, 2018

    @gingerbeardman
    Contributor

    macOS Human Interface Guidelines

    https://developer.apple.com/macos/human-interface-guidelines/buttons/push-buttons/

    Configure a push button the user is highly likely to select as the default. A default push button is prominent in appearance and automatically performs its action when the user presses Return. There can only be a single default button in a view.

    Default is always rightmost, usually lower right of dialog, filled with highlight colour, activates using Return.

    Secondary option always has focus, outlined with highlight colour, usually to the left of the default option, activates using Space.

    Include a trailing ellipsis in the title when a push button opens another window, dialog, or app. For example, the Edit buttons in the AutoFill pane of Safari Preferences include ellipses because they open other dialogs or windows that let the user modify autofill values.

    Avoid providing introductory labels. Push button titles should be descriptive enough that a label is unnecessary.

    Separate destructive buttons from nondestructive controls. Destructive buttons should be far enough away from other elements that the user has to make an intentional effort to click the button.

  12. billygriffin commented on Oct 2, 2018

    @billygriffin
    Contributor

    @gingerbeardman Where do you see that "default is always rightmost" in the macOS guidelines? I couldn't find that anywhere, and a quick check of deleting something in my trash runs counter to that.

    screen shot 2018-10-02 at 9 00 35 am

  13. koenpunt commented on Oct 2, 2018

    @koenpunt
    Contributor

    What @billygriffin says is true.

    And it's also not true that the secondary item is always focussed. If you do CMD+ALT+BACKSPACE on a file, you'll get an dialog that has the Cancel button as primary, which is also the focussed button;

    image

  14. gingerbeardman commented on Oct 2, 2018

    @gingerbeardman
    Contributor

    @billygriffin @koenpunt

    General case

    Place buttons where people expect them. In general, the button people are most likely to choose should be on the right. The default button should always be on the right. Cancel buttons are typically on the left.

    Empty Trash (destructive) case

    Include a Cancel button when there’s a destructive button. A Cancel button provides a clear, safe way to opt out of a destructive action. Consider making the Cancel button the default button too, requiring the user to intentionally click a button to continue with the destructive action.

    https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/alerts/


    In full...

    Alert Buttons

    Generally, use two-button alerts. Two-button alerts provide an easy choice between two alternatives. Single-button alerts inform, but give no control over the situation. Alerts with three or more buttons create complexity.

    Give alert buttons succinct, logical titles. The best button titles consist of one or two words that describe the result of clicking the button. As with all button titles, use title-style capitalization and no ending punctuation. To the extent possible, use verbs and verb phrases that relate directly to the alert title and message—for example, View All, Reply, or Ignore. Use OK for simple acceptance. Avoid using Yes and No.

    Ensure that the default button title reflects the action the button performs. Avoid using OK for the default button unless the alert is purely informational. The meaning of OK can be unclear even in alerts that ask if the user is sure they want to do something. For example, does OK mean “OK, I want to complete the action” or “OK, I now understand the negative results my action would have caused”? A specific button title like Erase, Convert, Clear, or Delete helps the user understand the action they’re taking.

    Place buttons where people expect them. In general, the button people are most likely to choose should be on the right. The default button should always be on the right. Cancel buttons are typically on the left.

    Label cancellation buttons appropriately. A button that cancels an alert’s action should always be labeled Cancel.

    Include a Cancel button when there’s a destructive button. A Cancel button provides a clear, safe way to opt out of a destructive action. Consider making the Cancel button the default button too, requiring the user to intentionally click a button to continue with the destructive action.

    Allow the Esc (Escape) key and Command-Period (.) keyboard shortcut to cancel alerts. Pressing Esc or Command-Period while an alert is visible should produce the same effect as clicking the Cancel button—that is, the alert is dismissed without performing any action. If your alert doesn’t have a Cancel button, consider implementing a cancel action in your code that runs when Esc or Command-Period is pressed.

    Consider offering time-saving keyboard shortcuts for all buttons. For example, you could let people activate a Print button by pressing the P key, or a Don't Save button by pressing the D or Delete key.

  15. j-f1 commented on Oct 2, 2018

    @j-f1
    Contributor

    It seems like Cancel should be the default when the action is destructive, and the destructive action should be on the right since that’s the most common action.

  16. gingerbeardman commented on Oct 2, 2018

    @gingerbeardman
    Contributor

    @j-f1 indeed, see point 6 in the list (and my edit above)

  17. koenpunt commented on Oct 2, 2018

    @koenpunt
    Contributor

    It seems like Cancel should be the default when the action is destructive, and the destructive action should be on the right since that’s the most common action.

    Btw, moving a file to the trash is not seen as destructive apparently, because there the cancel button is not the default.

  18. gingerbeardman commented on Oct 2, 2018

    @gingerbeardman
    Contributor

    @koenpunt the default button is the blue one

  19. koenpunt commented on Oct 2, 2018

    @koenpunt
    Contributor

    Oh I meant emptying the trash;

    image

  20. gingerbeardman commented on Oct 2, 2018

    @gingerbeardman
    Contributor

    Interesting.

    So immediate deletion is seen as destructive, but emptying the Trash is not.

    I could only guess at the reasoning.

  21. removed
    help wanted
    on Mar 15, 2019
  22. ruggi99 commented on Jun 8, 2020

    @ruggi99
    Contributor

    @tierninho could you update this issue if you have the time?

  23. added
    not-planned
    on Jul 8, 2024
  24. sergiou87 commented on Sep 24, 2024

    @sergiou87
    Member

    This was fixed in recent accessibility work

  25. gingerbeardman commented on Sep 24, 2024

    @gingerbeardman
    Contributor

    Praise be!

    Only 7 years, some sort of record I imagine.

    All the more confusing to have "not-planned" label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnot-planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions