Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Fix the picker suggestion items flashing issue.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "lijunle@gmail.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent<
// (undocumented)
protected suggestionElement: React.RefObject<ISuggestions<T>>;
// (undocumented)
protected SuggestionOfProperType: new (props: ISuggestionsProps<T>) => Suggestions<T>;
// (undocumented)
protected suggestionStore: SuggestionsController<T>;
// (undocumented)
protected updateSuggestions(suggestions: any[]): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export type IPickerAriaIds = {

const getClassNames = classNamesFunction<IBasePickerStyleProps, IBasePickerStyles>();

const StyledSuggestions = styled<ISuggestionsProps<any>, ISuggestionsStyleProps, ISuggestionsStyles>(
Suggestions,
suggestionsStyles,
undefined,
{ scope: 'Suggestions' }
);

export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent<P, IBasePickerState> implements IBasePicker<T> {
// Refs
protected root = React.createRef<HTMLDivElement>();
Expand All @@ -57,7 +64,6 @@ export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent<

protected selection: Selection;
protected suggestionStore: SuggestionsController<T>;
protected SuggestionOfProperType = Suggestions as new (props: ISuggestionsProps<T>) => Suggestions<T>;
protected currentPromise: PromiseLike<any> | undefined;
protected _ariaMap: IPickerAriaIds;
private _id: string;
Expand Down Expand Up @@ -277,17 +283,7 @@ export class BasePicker<T, P extends IBasePickerProps<T>> extends BaseComponent<
}

protected renderSuggestions(): JSX.Element | null {
const TypedSuggestions = this.SuggestionOfProperType;

// TODO:
// Move this styled component in a separate file and make it available to the public API.
// This should be done after rewriting pickers to use a composition pattern instead of inheritance.
const StyledTypedSuggestions = styled<ISuggestionsProps<T>, ISuggestionsStyleProps, ISuggestionsStyles>(
TypedSuggestions,
suggestionsStyles,
undefined,
{ scope: 'Suggestions' }
);
const StyledTypedSuggestions: React.StatelessComponent<ISuggestionsProps<T>> = StyledSuggestions;

return this.state.suggestionsVisible && this.input ? (
<Callout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ export interface ISuggestionsState {
selectedActionType: SuggestionActionType;
}

const StyledSuggestionsItem = styled<ISuggestionItemProps<any>, ISuggestionsItemStyleProps, ISuggestionsItemStyles>(
SuggestionsItem,
suggestionsItemStyles,
undefined,
{ scope: 'SuggestionItem' }
);

export class Suggestions<T> extends BaseComponent<ISuggestionsProps<T>, ISuggestionsState> {
protected _forceResolveButton = React.createRef<IButton>();
protected _searchForMoreButton = React.createRef<IButton>();
protected _selectedElement = React.createRef<HTMLDivElement>();
private SuggestionsItemOfProperType = SuggestionsItem as new (props: ISuggestionItemProps<T>) => SuggestionsItem<T>;
private activeSelectedElement: HTMLDivElement | null;
private _classNames: Partial<IProcessedStyleSet<ISuggestionsStyles>>;

Expand Down Expand Up @@ -307,19 +313,7 @@ export class Suggestions<T> extends BaseComponent<ISuggestionsProps<T>, ISuggest

let { suggestions } = this.props;

const TypedSuggestionsItem = this.SuggestionsItemOfProperType;

// TODO:
// Move this styled component in a separate file and make it available to the public API.
// This should be done after rewriting pickers to use a composition pattern instead of inheritance.
const StyledTypedSuggestionsItem = styled<ISuggestionItemProps<T>, ISuggestionsItemStyleProps, ISuggestionsItemStyles>(
TypedSuggestionsItem,
suggestionsItemStyles,
undefined,
{
scope: 'SuggestionItem'
}
);
const StyledTypedSuggestionsItem: React.StatelessComponent<ISuggestionItemProps<T>> = StyledSuggestionsItem;

let selectedIndex = -1;
suggestions.some((element, index) => {
Expand Down