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(frontend/presenter): clicking on plus should not toggle next line #451

Merged
merged 5 commits into from
May 24, 2020

Conversation

AkalUstat
Copy link
Contributor

excludes the classNames which are not 'desktop app' or 'presenter'

fixes #401

@AkalUstat AkalUstat changed the title fix(frontend): clicking on plus should not activate line switch fix(frontend): clicking on plus should not toggle next line Mar 10, 2020
@bhajneet
Copy link
Member

bhajneet commented Mar 11, 2020

This looks good to me. Pending final review from Harjot.

@AkalUstat In future please use the imperative mood in commit messages (rule 5), meaning "as if giving a command or instruction". So a very small change from ...clicking on plus... to ...click on plus.... And lastly to use the body of the commit message to explain "why?". It's very obvious what/how it was done, so that's not required. This time is fine, you don't have to amend the commit msg.

@Harjot1Singh might be best to link this in our commit guidelines if not done so already

Copy link
Member

@Harjot1Singh Harjot1Singh left a comment

Choose a reason for hiding this comment

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

Also need to check on edge cases:

  • Click on lines within presenter should still allow toggle next line

const goNextLine = useCallback( () => {
const goNextLine = useCallback((e) => {
// exclude anything other than the main window
if( e.target.parentNode.className !== 'desktop app' && e.target.parentNode.className !== 'presenter' ) return
Copy link
Member

Choose a reason for hiding this comment

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

A better way would be to use the className of the Presenter so that it is resilient to changes in the future (e.g. you can view the controller on iPad, but this approach would not work since it only includes desktop)

Copy link
Contributor Author

@AkalUstat AkalUstat Mar 17, 2020

Choose a reason for hiding this comment

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

im not sure i understand. Did it this way because sometimes the parent node came out as 'desktop app' or 'presenter' depending on where i clicked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2020-03-17 at 3 54 34 PM
for example if i clicked the main view area it gave me classname 'desktop app
and at the bottom it gave me 'presenter'

Copy link
Member

Choose a reason for hiding this comment

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

I meant, programmatically acquire the className from the ref of the presenter. That way, if we change the presenter className for whatever reason, we won't have a regression here because we forgot to update it here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure i get it still

@@ -72,7 +72,9 @@ const NavigatorHotKeys = ( { active, children, mouseTargetRef } ) => {
}
}, [ lines, lineId ] )

const goNextLine = useCallback( () => {
const goNextLine = useCallback((e) => {
Copy link
Member

Choose a reason for hiding this comment

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

Ey ey, use the linter! Style is wrong

Copy link
Member

Choose a reason for hiding this comment

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

Also, always prefer being a little more explicit with event over e

@AkalUstat
Copy link
Contributor Author

Also need to check on edge cases:

* [ ]  Click on lines within presenter should still allow toggle next line

yea it works

@AkalUstat
Copy link
Contributor Author

@bhajneet @Harjot1Singh This is ready for review

becomes 'controller-container` instead of presenter.
In this case, we check the targetClass or its parent node's class
(which if the target is controller container, will be presenter) */
if ( mouseTarget.className !== targetClass
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 can use De Morgan’s law to make this more readable imo.

if(!(mouseTarget.className === targetClass || mouseTarget.className === parentClass))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well actually it’s perfectly fine as is

Copy link
Member

Choose a reason for hiding this comment

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

even better [ targetClass, parentClass ].includes(mouseTarget.className)

puts the two class names in an array and checks if the target className is in the array
Copy link
Member

@Harjot1Singh Harjot1Singh left a comment

Choose a reason for hiding this comment

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

Just stylistic changes, happy with the rest 👍

Btw, your commit messages are not quite right, but I'll be squashing this PR anyway.

const goNextLine = useCallback( event => {
const { current: mouseTarget } = mouseTargetRef

const targetClass = event.target.className
Copy link
Member

Choose a reason for hiding this comment

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

Destructure event.target.etc at the top.

becomes 'controller-container` instead of presenter.
In this case, we check the targetClass or its parent node's class
(which if the target is controller container, will be presenter) */
if ( ![ targetClass, parentClass ].includes( mouseTarget.className ) ) return
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it's just me, but it does look a little strange to have 2 consecutive return statements, consider combining into one?

@AkalUstat
Copy link
Contributor Author

AkalUstat commented May 24, 2020

Just stylistic changes, happy with the rest 👍

Btw, your commit messages are not quite right, but I'll be squashing this PR anyway.

yea i keep doing brackets for some reason and i use random tags

and combine both if statements that cancel the event into one
@Harjot1Singh Harjot1Singh changed the title fix(frontend): clicking on plus should not toggle next line fix(frontend/presenter): clicking on plus should not toggle next line May 24, 2020
@Harjot1Singh Harjot1Singh merged commit 159ef6a into shabados:dev May 24, 2020
@AkalUstat AkalUstat deleted the 401-dont-advance-plus branch May 24, 2020 18:28
Harjot1Singh added a commit that referenced this pull request Oct 15, 2020
Bug introduced during #451, where the checks are too stringent.
Harjot1Singh added a commit that referenced this pull request Oct 15, 2020
#601)

Bug introduced during #451, where the checks are too stringent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't advance line when clicking "+" sign to open controller
3 participants