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

fix(FEC-9450): keyboard prevent non relevant events #440

Merged
merged 10 commits into from
Oct 30, 2019
Merged

Conversation

Yuvalke
Copy link
Contributor

@Yuvalke Yuvalke commented Oct 27, 2019

Description of the Changes

Special key like alt, ctrl and cmd didn't work with keys that already mapped.
prevent only combine keys with handlers.

CheckLists

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • test are passing in local environment
  • Travis tests are passing (or test results are not worse than on master branch :))
  • Docs have been updated

Speical key like alt,cntrl and cmd didn't work with keys that already maped.
prevent only combine keys with handlers.
@Yuvalke Yuvalke requested a review from a team October 27, 2019 15:36
@@ -105,8 +104,8 @@ class Keyboard extends Component {
*
* @memberof Keyboard
*/
keyboardHandlers: {[key: number]: Function} = {
[KeyMap.SPACE]: () => {
keyboardHandlers: {[key: number]: (event: KeyboardEvent) => {preventDefault: boolean, payload: any}} = {
Copy link
Contributor

Choose a reason for hiding this comment

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

extract to type {preventDefault: boolean, payload: any}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,5 @@
// @flow
declare type EventHandlerOption = {
Copy link
Contributor

Choose a reason for hiding this comment

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

this name is extremely generic and will apply to anything which is an event, while it is a specific form for a specific handler.

Suggested change
declare type EventHandlerOption = {
declare type KeyboardEventResult = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could use it in other cases like this, why do you want to rename it to specific existing use case?

Copy link
Contributor

Choose a reason for hiding this comment

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

cause it is specific, where else will you have prevent default and payload response?
The response object is tightly coupled with the implementation of this class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we didn't use, it could be used on the future..
it's use case I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

unless you see a concrete use case then it is specific.
refactor to generalize a use case later is always possible, but there is no benefit or use case here.
Let's change it to fit the part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

OrenMe
OrenMe previously approved these changes Oct 29, 2019
}
return {preventDefault: false, payload: null};
Copy link
Contributor

Choose a reason for hiding this comment

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

if {preventDefault: false, payload: null} repeats everywhere extract it to a const and use that.
const unhandledKeyboardEventResult = {preventDefault: false, payload: null};

* @memberof Keyboard
*/
get unhandledKeyboardEventResult(): KeyboardEventResult {
return {preventDefault: false, payload: null};
Copy link
Contributor

Choose a reason for hiding this comment

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

as it static const make it a const unhandledKeyboardEventResult: KeyboardEventResult = {preventDefault: false, payload: null};
place it in top of file and use it internally.

@Yuvalke Yuvalke merged commit 1d2dd77 into master Oct 30, 2019
@Yuvalke Yuvalke deleted the FEC-9450 branch October 30, 2019 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants