"Enter" key on focused Submit button in modal on macOS

Issue

From some version (I don’t know which, maybe with UXP 3?) on, XD on macOS cancels the dialog when pressing the Enter key on macOS while the submit button is focused. As this was different before (and an integral part of my plugin’s UX), I assume this is a bug, which is why I post it here.

Steps to reproduce

  • install Lorem Ipsum v1.3.0-rc.1
  • Run the plugin on macOS using Cmd+Opt+L
  • The plugin dialog gets shown and its Insert Text button hightlighted
  • Press Enter
  • The plugin cancels, like if you clicked Cancel

Expected Behavior

Pressing Enter should trigger the active button (or at least not trigger cancelling!)

Actual Behavior

The dialog gets canceled, as if a user pressed a Cancel button or the ESC key (the promise rejects with 'reasonCanceled'). Furthermore, a warning sound indicating the key cannot get used in this context gets played.

Additional information

I was able to temporarily fix this by adding a 'keydown' listener on the button where I manually resolve the Promise, cf. Release Candidate 2. The sound about an “invalid” shortcut still gets played, but the plugin, once again, works as intended.

Side-note: This might be related to my other bug with focusing behavior in UXP 3, cf. `autofocus` on Windows

What version of macOS do you see this on?

1 Like

10.13 High Sierra on the latest version of XD (can’t check the version number right now), as of today…

My Mac is too old to update it to any newer macOS version :neutral_face: .

IIUC I might have the same issue on OSX (haven’t confirmed on Windows). I’m also on High Sierra and it closes the window on enter. I don’t know if this is a bug or not but I’m able to cancel it with event.preventDefault();

Can you add an on submit handler to your form and call preventDefault()?

onsubmit(e) {
    formSubmit(e)
} 

function formSubmit(event) {
	  event.preventDefault();
}