frend / frend.co

Frend — A collection of accessible, modern front-end components.
http://frend.co
MIT License
635 stars 25 forks source link

Test for modifier when listening to key events #75

Closed waldbaerkoch closed 8 years ago

waldbaerkoch commented 8 years ago

I would expect the components not to swallow key events with modifiers like Alt+ArrowLeft for history back.

adamduncan commented 8 years ago

Good point, thanks @waldbaerkoch. We'll look into a cross-platform/browser fix for this and make sure we're not catching unnecessary key events.

adamduncan commented 8 years ago

Added modifier guard clauses in the keydown handlers for altKey and metaKey. In fix branch commit c44af13

Is this condition too simplistic? Keeps it concise without getting into getModifierState territory.

let isModifierKey = (e.metaKey || e.altKey) ? true : false;
if (isModifierKey) return;

Will do more cross-browser testing, and open to alternative approaches.

adamduncan commented 8 years ago

Just reread that and realised the ternary statement is redundant. Will refactor. :sleeping:

adamduncan commented 8 years ago

Tested the above approach in Chrome/FF/IE on Windows and Chrome/Safari on Mac. I'm happy it's resolved the issue.

@thomasdigby, @waldbaerkoch - are you aware of a better approach for this key event side-effect?

waldbaerkoch commented 8 years ago

I think, that is an appropriate solution. Thanks.

thomasdigby commented 8 years ago

Merge away 🏌

adamduncan commented 8 years ago

Closed with #77