mui-toolpad icon indicating copy to clipboard operation
mui-toolpad copied to clipboard

Deploy with keyboard enter

Open bytasv opened this issue 3 years ago • 2 comments

  • Closes https://github.com/mui/mui-toolpad/issues/1164

https://user-images.githubusercontent.com/437214/196986160-a863dc7b-3e63-4ccf-8ee3-2a431cb88574.mov

@oliviertassinari in your proposed implementation you have added condition to not trigger event when shift is down, I'm not sure why exactly that is needed though. Please lemme know if that must be added for some reason

IMO there is only one drawback with my implementation - if we really want to allow deploying on mac only with cmd + enter then I should do some OS sniffing as right now we can deploy with both cmd + enter and ctrl + enter

bytasv avatar Oct 20 '22 15:10 bytasv

Your Render PR Server URL is https://toolpad-pr-1188.onrender.com.

Follow its progress at https://dashboard.render.com/web/srv-cd8m86ha6gdttutvskeg.

render[bot] avatar Oct 20 '22 15:10 render[bot]

you have added condition to not trigger event when shift is down, I'm not sure why exactly that is needed though

@bytasv I have copied the logic from the data grid. I don't know why it's here. No objections to remove it.

oliviertassinari avatar Oct 20 '22 16:10 oliviertassinari

I'm not sure why exactly that is needed though

So that when someone somewhere sometime in the future defines the Cmd+Shift+Enter shortcut, this one doesn't accidentally fire?

Janpot avatar Oct 21 '22 07:10 Janpot

@Janpot I copied it from here precisely: https://github.com/mui/mui-x/pull/5744/files#diff-f5bd889280d2db3f858e79916957e7f360ba3392b12b0c2902f9b5b4b9a84d3bR62 you can see the logic in action in this demo: https://mui.com/x/react-data-grid/recipes-editing/#multiline-editing. I had a look at the rest of the codebase, they usually don't ignore the shift key.

@cherniavskii What was the intent with the Shift key, e.g. https://github.com/mui/mui-x/pull/5744#discussion_r944358320?

oliviertassinari avatar Oct 21 '22 10:10 oliviertassinari

So that when someone somewhere sometime in the future defines the Cmd+Shift+Enter shortcut, this one doesn't accidentally fire?

In that case we should guard that no other key is pressed, because there could also be other shortcuts in the future, that we might not be aware of right now, cmd+option+enter, cmd+tab+enter, etc.. (whatever they would do)

bytasv avatar Oct 21 '22 10:10 bytasv

@Janpot please take a look. I moved key handler to the form itself, as well as tweaked DialogForm component so we could get this functionality everywhere where DialogForm is used.

bytasv avatar Oct 21 '22 11:10 bytasv

@oliviertassinari

What was the intent with the Shift key, e.g. https://github.com/mui/mui-x/pull/5744#discussion_r944358320?

The intention was to for Enter and Shift + Enter to add new line and only exit editing on Escape or Ctrl + Enter

cherniavskii avatar Oct 21 '22 13:10 cherniavskii

I have just used the feature to deploy, nice :)

oliviertassinari avatar Oct 25 '22 17:10 oliviertassinari