Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
BaseComponent,
EventGroup,

Copy link
Copy Markdown
Member

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 change and 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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,
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
This is help reduce our rendering time to glass.


delete this._initialFocusedIndex;
}
Expand Down