Docking the Comment Dialog
Review Request #10213 — Created Oct. 10, 2018 and updated
Comment Dialog: Docking
When reviews have the tendency to get longer the Comment Dialog
becomes harder to keep track of. To fix this,the comment
dialog has been docked to the page. This means when users open
up a comment, the dialog will stay on the page with the user
during the review process.Users can drag around the dialog with ease with the use of
jQuery UI and standard jQuery mouse events. Functions have been
implemented to ensure that the Comment Dialog remains in the content
area. This is to prevent users from accidentally moving the dialog
off-screen.
Ran and passed all of the JavaScript Unit Tests.
Added a new test to check whether the position was being set
correctly onmousedown
andmouseup
.
Description | From | Last Updated |
---|---|---|
Col: 13 'newTop' is defined but never used. |
![]() |
|
Col: 53 Missing semicolon. |
![]() |
|
Col: 18 'getTop' is defined but never used. |
![]() |
|
Col: 34 Missing semicolon. |
![]() |
|
Col: 31 Missing semicolon. |
![]() |
|
Most of these could be declared const. |
|
|
Col: 18 'getTop' is defined but never used. |
![]() |
|
Col: 34 Missing semicolon. |
![]() |
|
Col: 31 Missing semicolon. |
![]() |
|
Col: 18 'getTop' is defined but never used. |
![]() |
|
Col: 34 Missing semicolon. |
![]() |
|
Col: 31 Missing semicolon. |
![]() |
|
Col: 71 Missing semicolon. |
![]() |
|
Col: 41 Missing semicolon. |
![]() |
|
Col: 15 'isAbove' was used before it was defined. |
![]() |
|
Col: 10 Missing semicolon. |
![]() |
|
Col: 31 Missing semicolon. |
![]() |
|
trailing whitespace. |
|
|
This can just be .css('position', 'fixed'). No need to construct an object. If you want to keep it as an … |
|
|
Trailing whitespace. |
|
|
Only the comments before a function should be /**. Regular multiline comments can use /*. Same below. |
|
|
Trailing whitespace. Missing space after period. |
|
|
This can be a single computation. const top = commentBox.offset().top - 8; |
|
|
What is 8 here? where does this come from? |
|
|
You can replace this with: commentBox.css({ 'position': 'absolute', 'top': `${top}px`, }); |
|
|
This can be a single computation. Always space around binary operators. |
|
|
The parentheses are redundant. |
|
|
You can replace this with: commentBox.css({ 'position': 'fixed', 'top': `${top}px`, }); |
|
|
Doc comments should be of the form: ``` /* * Single line summary (in imperitive mood). * * Multi-line display. … |
|
|
Trailing whitespace. Dialog -> dialog Checks -> Check. |
|
|
We generally use function statements in this case, e.g. function isAbove() { // ... } Same with isBelow below. |
|
|
This should be named something like isTopPosition because it is a boolean. A variable named topPosition would be, e.g., the … |
|
|
Where does 8 come from? |
|
|
Blank line between these. |
|
|
Replace with: return topPosition || offsetTop === 0; |
|
|
Doc comments should be of the form: ``` /* * Single line summary (in imperitive mood). * * Multi-line display. … |
|
|
Replace with: return commentBox.offset().top > bottomOfScreen; |
|
|
Trailing whitespace. |
|
|
stop: function(event, ui) { |
|
|
You can replace this with: ui.helper.css({ 'position': 'fixed', 'top': `${ui.helper.scrollTop()}px`, }); |
|
|
} else if (isBelow()) { |
|
|
You can replace this with: ui.helper.css({ 'position': 'fixed', 'top': `${bottomOfScreen}px`, }); |
|
|
Trailing whieespace. |
|
|
Undo this. |
|
|
Undo this. |
|
|
Trailing whitespace. |
|
|
Col: 10 Unnecessary semicolon. |
![]() |
|
Col: 10 Unnecessary semicolon. |
![]() |
|
You have some trailing whitespace over here. |
|
|
There is some whitespace here |
|
|
There is some whitespace here |
|
|
Col: 17 'x' is defined but never used. |
![]() |
|
Col: 17 'y' is defined but never used. |
![]() |
|
You could chain these jQuery methods to keep the code a bit more concise like this: commentBox .on('mousdown', () => … |
|
|
Is there a reason you need both eTop and top? Is it possible to condense these two lines down to … |
|
|
Your comment makes it super clear what the two conditions are to return true, but based on the names of … |
|
|
Should this comment still be here? |
|
|
This should have one more space added to it, to keep it in line with the it() function. |
|
|
There should be a newline between these two lines. |
|
|
There should be a newline between these two lines. |
|
Change Summary:
These are the things I have been experimenting, with keeping the Comment Dialog fixed to the page
Branch: |
|
||||
---|---|---|---|---|---|
Commit: |
|
||||
Diff: |
Revision 2 (+59 -6) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 2) Show all issues -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 2) Col: 53 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 2) Col: 18 'getTop' is defined but never used.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 2) Col: 34 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 2) Col: 31 Missing semicolon.
Change Summary:
Trying out Mike's proposed change
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+41 -6) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 3) Col: 18 'getTop' is defined but never used.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 3) Col: 34 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 3) Col: 31 Missing semicolon.
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 3) Most of these could be declared
const
.
Change Summary:
So I found a bug that move the dialog box down by 8 pixels for some reason, I plan to look into that further.
I also contained the box to the document, since when the box would go into a negativetop
value it would break the
Comment dialog box.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+68 -6) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 4) Col: 18 'getTop' is defined but never used.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 4) Col: 34 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 4) Col: 31 Missing semicolon.
Change Summary:
This change will fix the bugs I had when the cursor would leave the content area.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+58 -7) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 5) Col: 71 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 5) Col: 41 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 5) Col: 15 'isAbove' was used before it was defined.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 5) Col: 10 Missing semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 5) Col: 31 Missing semicolon.
Change Summary:
Updated the description and the Summary.
Summary: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 6 (+89 -8) |
Checks run (2 succeeded)
-
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) This can just be
.css('position', 'fixed')
.No need to construct an object.
If you want to keep it as an object, space after
:
. -
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Only the comments before a function should be
/**
. Regular multiline comments can use/*
.Same below.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Trailing whitespace.
Missing space after period.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) This can be a single computation.
const top = commentBox.offset().top - 8;
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) What is
8
here? where does this come from? -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) You can replace this with:
commentBox.css({ 'position': 'absolute', 'top': `${top}px`, });
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) This can be a single computation.
Always space around binary operators.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) The parentheses are redundant.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) You can replace this with:
commentBox.css({ 'position': 'fixed', 'top': `${top}px`, });
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Doc comments should be of the form:
```
/*
* Single line summary (in imperitive mood).
* * Multi-line display.
* * Returns:
* returntype:
* Description of return value.
/ -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Trailing whitespace.
Dialog -> dialog
Checks -> Check.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) We generally use
function
statements in this case, e.g.function isAbove() { // ... }
Same with
isBelow
below. -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) This should be named something like
isTopPosition
because it is a boolean. A variable namedtopPosition
would be, e.g., the y coordinate of the top position. -
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Replace with:
return topPosition || offsetTop === 0;
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Doc comments should be of the form:
```
/*
* Single line summary (in imperitive mood).
* * Multi-line display.
* * Returns:
* returntype:
* Description of return value.
/ -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) Replace with:
return commentBox.offset().top > bottomOfScreen;
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) stop: function(event, ui) {
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) You can replace this with:
ui.helper.css({ 'position': 'fixed', 'top': `${ui.helper.scrollTop()}px`, });
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 6) You can replace this with:
ui.helper.css({ 'position': 'fixed', 'top': `${bottomOfScreen}px`, });
-
-
-
-
Change Summary:
Addressing some of Barret's comments
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+81 -9) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 7) Col: 10 Unnecessary semicolon.
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 7) Col: 10 Unnecessary semicolon.
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 7) You have some trailing whitespace over here.
Change Summary:
Added Unit Tests and updated comments
Testing Done: |
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
||||||||||||
Diff: |
Revision 8 (+92 -10) |
Checks run (1 failed, 1 succeeded)
JSHint
-
reviewboard/static/rb/js/views/tests/commentDialogViewTests.js (Diff revision 8) Col: 17 'x' is defined but never used.
-
reviewboard/static/rb/js/views/tests/commentDialogViewTests.js (Diff revision 8) Col: 17 'y' is defined but never used.
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 8) There is some whitespace here
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 8) There is some whitespace here
Change Summary:
Removing WIP tag, and editing some of the tests
Summary: |
|
|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||
Commit: |
|
|||||||||||||||
Diff: |
Revision 9 (+76 -10) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 9) Should this comment still be here?
-
reviewboard/static/rb/js/views/tests/commentDialogViewTests.js (Diff revision 9) This should have one more space added to it, to keep it in line with the it() function.
-
reviewboard/static/rb/js/views/tests/commentDialogViewTests.js (Diff revision 9) There should be a newline between these two lines.
-
reviewboard/static/rb/js/views/tests/commentDialogViewTests.js (Diff revision 9) There should be a newline between these two lines.
-
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 9) You could chain these jQuery methods to keep the code a bit more concise like this:
commentBox .on('mousdown', () => {...}) .on('mouseup', () => {...})
-
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 9) Is there a reason you need both
eTop
andtop
? Is it possible to condense these two lines down toconst top = commentBox.offset().top
? -
reviewboard/static/rb/js/views/commentDialogView.es6.js (Diff revision 9) Your comment makes it super clear what the two conditions are to return true, but based on the names of these variables it's not super clear. Maybe you could try
isTopPosition
->isOutsideContentArea
andisOffsetTop
->isAtTopOfDocument
(or something like that)?
Change Summary:
Addressing the changes brought up by Sarah, Storm and Bola
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 10 (+77 -9) |