Skip to content

Commit

Permalink
Expose showRemoveButton on ExtendedPeoplePicker (#7904)
Browse files Browse the repository at this point in the history
* Expose SuggestionItem X button to ExtendedPicker

Adjust types to expose the SuggestionItem X button to the
ExtendedPicker. Parameterize the extended people picker to
accurately reflect its usage + the type constraints on it.

* remove extra comment

* changefile

* update public api

* make backwards compatible

* regen api

* apply suggestion from @JasonGore

* remove TODO comment
  • Loading branch information
Adjective-Object authored and msft-github-bot committed Feb 14, 2019
1 parent ea1c597 commit 3551e64
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Fix type IBaseFloatingPickerSuggestionProps in ExtendedPeoplePicker, expose showRemoveButtons",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1848,13 +1848,6 @@ interface IBaseFloatingPickerState {
suggestionsVisible?: boolean;
}

// @public (undocumented)
interface IBaseFloatingPickerSuggestionProps {
footerItemsProps?: ISuggestionsHeaderFooterProps[];
headerItemsProps?: ISuggestionsHeaderFooterProps[];
shouldSelectFirstItem?: () => boolean;
}

// @public
interface IBasePicker<T> {
focus: () => void;
Expand Down Expand Up @@ -12845,6 +12838,7 @@ module ZIndexes {
// WARNING: Unsupported export: groupTwo
// WARNING: Unsupported export: Fabric
// WARNING: Unsupported export: Facepile
// WARNING: Unsupported export: IBaseFloatingPickerSuggestionProps
// WARNING: Unsupported export: FocusZoneTabbableElements
// WARNING: Unsupported export: FocusZoneTabbableElements
// WARNING: Unsupported export: Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class ExtendedPeoplePickerBasicExample extends React.Component<{}, IPeopl
};

this._suggestionProps = {
showRemoveButtons: true,
headerItemsProps: [
{
renderItem: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as stylesImport from './BaseFloatingPicker.scss';
import { BaseComponent, css, KeyCodes } from '../../Utilities';
import { Callout, DirectionalHint } from '../../Callout';
import { IBaseFloatingPicker, IBaseFloatingPickerProps, IBaseFloatingPickerSuggestionProps } from './BaseFloatingPicker.types';
import { IBaseFloatingPicker, IBaseFloatingPickerProps } from './BaseFloatingPicker.types';
import { ISuggestionModel } from '../../Pickers';
import { ISuggestionsControlProps } from './Suggestions/Suggestions.types';
import { SuggestionsControl } from './Suggestions/SuggestionsControl';
Expand Down Expand Up @@ -167,7 +167,7 @@ export class BaseFloatingPicker<T, P extends IBaseFloatingPickerProps<T>> extend
ref={this._resolveRef('suggestionsControl')}
completeSuggestion={this.completeSuggestion}
shouldLoopSelection={false}
{...this.props.pickerSuggestionsProps as IBaseFloatingPickerSuggestionProps}
{...this.props.pickerSuggestionsProps}
/>
</Callout>
) : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { ISuggestionModel } from '../../Pickers';
import { IPersonaProps } from '../../Persona';
import { ISuggestionsHeaderFooterProps } from './Suggestions/Suggestions.types';
import { ISuggestionsControlProps } from './Suggestions/Suggestions.types';
import { SuggestionsStore } from './Suggestions/SuggestionsStore';
import { IRefObject } from '../../Utilities';

Expand Down Expand Up @@ -143,18 +143,10 @@ export interface IBaseFloatingPickerProps<T> extends React.ClassAttributes<any>
suggestionItems?: T[];
}

export interface IBaseFloatingPickerSuggestionProps {
/**
* Whether or not the first selectable item in the suggestions list should be selected
*/
shouldSelectFirstItem?: () => boolean;

/**
* The header items props
*/
headerItemsProps?: ISuggestionsHeaderFooterProps[];
/**
* The footer items props
*/
footerItemsProps?: ISuggestionsHeaderFooterProps[];
}
/**
* Props which are passed on to the inner Suggestions component
*/
export type IBaseFloatingPickerSuggestionProps = Pick<
ISuggestionsControlProps<any>,
'shouldSelectFirstItem' | 'headerItemsProps' | 'footerItemsProps' | 'showRemoveButtons'
>;
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ export class SuggestionsControl<T> extends BaseComponent<ISuggestionsControlProp
protected _renderSuggestions(): JSX.Element {
const TypedSuggestions = this.SuggestionsOfProperType;

return (
<TypedSuggestions
ref={this._resolveRef('_suggestions')}
{...this.props as ISuggestionsCoreProps<T>}
suggestions={this.state.suggestions}
/>
);
return <TypedSuggestions ref={this._resolveRef('_suggestions')} {...this.props} suggestions={this.state.suggestions} />;
}

/**
Expand Down

0 comments on commit 3551e64

Please sign in to comment.