-
Notifications
You must be signed in to change notification settings - Fork 2.9k
make focus async to get rid of sync focus in detailsList #1193
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
Changes from 4 commits
aec48f0
9da9ba6
abe22bc
fcaf768
b2a57ba
d00a792
e8196ca
3d3e4bf
c8fbce1
7847ce3
95fd227
533c1b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import * as React from 'react'; | ||
| import { | ||
| BaseComponent, | ||
| EventGroup, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because you're removing usages of EventGroup, you need to remove the import to make tslint happy. |
||
| KeyCodes, | ||
| assign, | ||
|
|
@@ -52,7 +53,7 @@ const DEFAULT_RENDERED_WINDOWS_AHEAD = 2; | |
| const DEFAULT_RENDERED_WINDOWS_BEHIND = 2; | ||
|
|
||
| @withViewport | ||
| export class DetailsList extends React.Component<IDetailsListProps, IDetailsListState> implements IDetailsList { | ||
| export class DetailsList extends BaseComponent<IDetailsListProps, IDetailsListState> implements IDetailsList { | ||
| public static defaultProps = { | ||
| layoutMode: DetailsListLayoutMode.justified, | ||
| selectionMode: SelectionMode.multiple, | ||
|
|
@@ -71,7 +72,6 @@ export class DetailsList extends React.Component<IDetailsListProps, IDetailsList | |
| selectionZone: SelectionZone | ||
| }; | ||
|
|
||
| private _events: EventGroup; | ||
| private _selection: ISelection; | ||
| private _activeRows: { [key: string]: DetailsRow }; | ||
| private _dragDropHelper: DragDropHelper; | ||
|
|
@@ -108,15 +108,13 @@ export class DetailsList extends React.Component<IDetailsListProps, IDetailsList | |
| isSomeGroupExpanded: props.groupProps && !props.groupProps.isAllGroupsCollapsed | ||
| }; | ||
|
|
||
| this._events = new EventGroup(this); | ||
| this._selection = props.selection || new Selection({ onSelectionChanged: null, getKey: props.getKey }); | ||
| this._selection.setItems(props.items as IObjectWithKey[], false); | ||
| this._dragDropHelper = props.dragDropEvents ? new DragDropHelper({ selection: this._selection }) : null; | ||
| this._initialFocusedIndex = props.initialFocusedIndex; | ||
| } | ||
|
|
||
| public componentWillUnmount() { | ||
| this._events.dispose(); | ||
| if (this._dragDropHelper) { | ||
| this._dragDropHelper.dispose(); | ||
| } | ||
|
|
@@ -421,7 +419,7 @@ export class DetailsList extends React.Component<IDetailsListProps, IDetailsList | |
| if (this.refs.selectionZone) { | ||
| this.refs.selectionZone.ignoreNextFocus(); | ||
| } | ||
| row.focus(); | ||
| this._async.setTimeout(() => row.focus(), 0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jijizz I'm a little afraid of this change. Sometimes delaying focus can cause unexpected consequences. Did it improve perf in your measurements?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. measurement shows focus cost reduced from 30ms to 3 ms after changing it to async. |
||
|
|
||
| delete this._initialFocusedIndex; | ||
| } | ||
|
|
||
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.
Can you please run
rush changeand add a change request to patch, with comments:DetailsList: setting initial focus on a row is now done asynchronously to improve initial paint time by avoiding an unncessary layout.