-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
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 @Harjot1Singh might be best to link this in our commit guidelines if not done so already |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
yea it works |
excludes the classNames which are not 'desktop app' or 'presenter' fixes shabados#401
@bhajneet @Harjot1Singh This is ready for review |
c942f4c
to
602a90f
Compare
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 |
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
yea i keep doing brackets for some reason and i use random tags |
and combine both if statements that cancel the event into one
Bug introduced during #451, where the checks are too stringent.
excludes the classNames which are not 'desktop app' or 'presenter'
fixes #401