-
Notifications
You must be signed in to change notification settings - Fork 712
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
Maintain focus on hovered node table rows #2115
Conversation
933f6bb
to
9dfc19a
Compare
|
||
|
||
const log = debug('scope:table'); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went 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.
Works well and LGTM.
Very minor code issues.
focusedRowIndex: rowIndex, | ||
focusedNode: node | ||
}); | ||
log(`Focused row ${rowIndex}`); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
focusedRowIndex: null, | ||
focusedNode: null | ||
}); | ||
log('Unfocused row'); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
if (nodeRowIndex >= 0) { | ||
// If the focused node still exists in the table, we move it | ||
// to the hovered row, keeping the rest of the table sorted. | ||
moveElement(nodes, nodeRowIndex, focusedRowIndex); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
|
||
onMouseEnterRow(rowIndex, node) { | ||
this.debouncedUnfocusRow.cancel(); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@davkal and I discovered that row focusing was actually not working under some special conditions so I'm still working on this trying to cover all the cases. |
708f52e
to
2a70393
Compare
@davkal This slightly hacky solution should now work for all cases. PTAL. |
3432a7c
to
da1c6f5
Compare
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.
LGTM
Minimal code nits.
@@ -188,10 +261,11 @@ export default class NodeDetailsTable extends React.Component { | |||
colStyles={styles} | |||
columns={columns} | |||
onClick={onClickRow} | |||
onMouseLeaveRow={onMouseLeaveRow} | |||
onMouseEnterRow={onMouseEnterRow} | |||
onMouseEnter={() => { this.onMouseEnterRow(index, node); }} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -1,13 +1,15 @@ | |||
import React from 'react'; | |||
import classNames from 'classnames'; | |||
import { find, get, union, sortBy, groupBy, concat } from 'lodash'; | |||
import { find, get, union, sortBy, groupBy, concat, debounce, findIndex } from 'lodash'; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
// Use debouncing to prevent event flooding when e.g. crossing fast with mouse cursor | ||
// over the whole table. That would be expensive as each focus causes table to rerender. | ||
this.debouncedFocusRow = debounce(this.focusRow, TABLE_ROW_FOCUS_DEBOUNCE_INTERVAL); | ||
this.debouncedUnfocusRow = debounce(this.unfocusRow, TABLE_ROW_FOCUS_DEBOUNCE_INTERVAL); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
More sophisticated row focusing Keeping deleted focused nodes in the table Fixed focus debouncing
da1c6f5
to
1ef64cf
Compare
Fix for #1738. On hovering over a node in the table view, the row freezes its position until it loses focus. We only do that for the hovered row (and not for the selected one), with a short debounce to prevent excessive re-rendering. We keep the removed node's row in the table as long as it's focused so that the row would have a real freeze effect.
I think the best way to test this PR is by setting short lived nodes in the debug toolbar. To increase the table dynamics, I suggest temporarily dropping the constant in
debug-toolbar.js:232
to100
.