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

Maintain focus on hovered node table rows #2115

Merged
merged 3 commits into from
Jan 20, 2017
Merged

Conversation

fbarl
Copy link
Contributor

@fbarl fbarl commented Jan 6, 2017

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 to 100.

@fbarl fbarl self-assigned this Jan 6, 2017
@fbarl fbarl force-pushed the node-table-maintain-focus branch 2 times, most recently from 933f6bb to 9dfc19a Compare January 9, 2017 10:17
@fbarl fbarl changed the title [WIP] Maintain focus on hovered node table rows Maintain focus on hovered node table rows Jan 9, 2017
@fbarl fbarl requested a review from davkal January 9, 2017 10:21


const log = debug('scope:table');

This comment was marked as abuse.

Copy link
Contributor

@davkal davkal left a 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.

focusedRowIndex: null,
focusedNode: null
});
log('Unfocused row');

This comment was marked as abuse.

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.

}

onMouseEnterRow(rowIndex, node) {
this.debouncedUnfocusRow.cancel();

This comment was marked as abuse.

@fbarl fbarl changed the title Maintain focus on hovered node table rows [WIP] Maintain focus on hovered node table rows Jan 13, 2017
@fbarl
Copy link
Contributor Author

fbarl commented Jan 13, 2017

@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.

@fbarl fbarl force-pushed the node-table-maintain-focus branch 4 times, most recently from 708f52e to 2a70393 Compare January 18, 2017 14:25
@fbarl
Copy link
Contributor Author

fbarl commented Jan 18, 2017

@davkal This slightly hacky solution should now work for all cases. PTAL.

@fbarl fbarl changed the title [WIP] Maintain focus on hovered node table rows Maintain focus on hovered node table rows Jan 18, 2017
@fbarl fbarl force-pushed the node-table-maintain-focus branch 2 times, most recently from 3432a7c to da1c6f5 Compare January 19, 2017 12:41
Copy link
Contributor

@davkal davkal left a 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.

@@ -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.

// 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.

fbarl added 3 commits January 20, 2017 12:36
More sophisticated row focusing

Keeping deleted focused nodes in the table

Fixed focus debouncing
@fbarl fbarl force-pushed the node-table-maintain-focus branch from da1c6f5 to 1ef64cf Compare January 20, 2017 11:52
@fbarl fbarl merged commit 73b94d9 into master Jan 20, 2017
@fbarl fbarl deleted the node-table-maintain-focus branch January 20, 2017 12:21
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.

2 participants