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

preserve ctrl-f for macOS for moving forward #759

Merged
merged 2 commits into from Aug 14, 2019
Merged

preserve ctrl-f for macOS for moving forward #759

merged 2 commits into from Aug 14, 2019

Conversation

pd4d10
Copy link
Contributor

@pd4d10 pd4d10 commented Dec 30, 2018

  1. Extract common keys to utility
  2. Preserve ctrl-f for macOS for moving forward (Emacs style key binding)

Copy link

@bunyaban2516 bunyaban2516 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

กำลังศืกษาอยุ่

Copy link
Contributor

@Neitsch Neitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


const commonKeys = {
// Persistent search box in Query Editor
[isMacOs ? "Cmd-F" : "Ctrl-F"]: "findPersistent",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous behavior is definitely clowny. However, I don't quite trust the codemirror regex, since it only returns true for mountain lion and higher. Let's keep the former way for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use navigator.platform - much less clowny :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this UA detection seems needless here. Just make two entries, one for Cmd-F and one for Ctrl-F, with the same value. Thats the usual codemirror keymap MO

@@ -0,0 +1,16 @@
// keep consistent with codemirror:
// https://github.com/codemirror/CodeMirror/blob/ed8dfeb5e2/src/util/browser.js#L17
const isMacOs = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than sniffing the user agent, let's just use the platform API:

Suggested change
const isMacOs = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
const isMacOs = window.navigator.platform === 'MacIntel';

I don't think we need to worry about 'Mac68K' and 'MacPPC' which are other valid options for Mac platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


const commonKeys = {
// Persistent search box in Query Editor
[isMacOs ? "Cmd-F" : "Ctrl-F"]: "findPersistent",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this UA detection seems needless here. Just make two entries, one for Cmd-F and one for Ctrl-F, with the same value. Thats the usual codemirror keymap MO

@acao
Copy link
Member

acao commented Aug 12, 2019

ohhh i see. so if its mac, keep the default ctrl-f behavior?

@benjie
Copy link
Member

benjie commented Aug 12, 2019

@acao Exactly; many Mac users (including, until recently, me) expect the standard Emacs-style bindings to work. It's safe to bind Cmd-F everywhere, but on Mac we shouldn't bind Ctrl-F.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - thanks!

@benjie
Copy link
Member

benjie commented Aug 13, 2019

@acao Would you like to dismiss your review and then merge? (@Neitsch, do you have any further feedback?)

Copy link
Contributor

@Neitsch Neitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

None yet

6 participants