Skip to content

Commit

Permalink
Fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
skurger committed Jan 20, 2020
1 parent 9c505fe commit 62838fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
30 changes: 15 additions & 15 deletions packages/select/src/components/query-list/queryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,21 @@ export class QueryList<T> extends AbstractComponent2<IQueryListProps<T>, IQueryL
}
}

public setActiveItem(activeItem: T | ICreateNewItem | null) {
this.expectedNextActiveItem = activeItem;
if (this.props.activeItem === undefined) {
// indicate that the active item may need to be scrolled into view after update.
this.shouldCheckActiveItemInViewport = true;
this.setState({ activeItem });
}

if (isCreateNewItem(activeItem)) {
Utils.safeInvoke(this.props.onActiveItemChange, null, true);
} else {
Utils.safeInvoke(this.props.onActiveItemChange, activeItem, false);
}
}

/** default `itemListRenderer` implementation */
private renderItemList = (listProps: IItemListRendererProps<T>) => {
const { initialContent, noResults } = this.props;
Expand Down Expand Up @@ -486,21 +501,6 @@ export class QueryList<T> extends AbstractComponent2<IQueryListProps<T>, IQueryL
return getFirstEnabledItem(this.state.filteredItems, this.props.itemDisabled, direction, startIndex);
}

public setActiveItem(activeItem: T | ICreateNewItem | null) {
this.expectedNextActiveItem = activeItem;
if (this.props.activeItem === undefined) {
// indicate that the active item may need to be scrolled into view after update.
this.shouldCheckActiveItemInViewport = true;
this.setState({ activeItem });
}

if (isCreateNewItem(activeItem)) {
Utils.safeInvoke(this.props.onActiveItemChange, null, true);
} else {
Utils.safeInvoke(this.props.onActiveItemChange, activeItem, false);
}
}

private isCreateItemRendered(): boolean {
return (
this.canCreateItems() &&
Expand Down
7 changes: 2 additions & 5 deletions packages/select/src/components/select/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,8 @@ export class Suggest<T> extends React.PureComponent<ISuggestProps<T>, ISuggestSt
// The activeItem should always be the selectedItem when the Popover is first opened
// if the activeItem prop is not set. Set the activeItem on close so that there isn't
// a flash of the activeItem on screen.
const shouldResetActiveItemToSelectedItem = (
this.props.activeItem === undefined &&
this.state.selectedItem &&
!this.props.resetOnSelect
);
const shouldResetActiveItemToSelectedItem =
this.props.activeItem === undefined && this.state.selectedItem && !this.props.resetOnSelect;

if (this.queryList && shouldResetActiveItemToSelectedItem) {
// If the selectedItem prop is set then use it.
Expand Down

0 comments on commit 62838fc

Please sign in to comment.