Skip to content

Commit

Permalink
Adding an optional SelectionZone class name and also fixing remaining…
Browse files Browse the repository at this point in the history
… bugs in UnifiedPicker (#15652)
  • Loading branch information
nebhatna authored Oct 23, 2020
1 parent a933f3f commit 4da219b
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "UnifiedPicker: Fixing fluent bugs",
"packageName": "@fluentui/react-experiments",
"email": "nebhatna@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-10-22T20:57:31.406Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "SelectionZone: Adding an optional className prop",
"packageName": "@fluentui/react-internal",
"email": "nebhatna@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-10-22T20:57:57.716Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ const _suggestions = [
isSelected: false,
showRemoveButton: true,
},
{
key: '6',
id: '6',
displayText: 'Suggestion 6',
item: people[5],
isSelected: false,
showRemoveButton: true,
},
{
key: '7',
id: '7',
displayText: 'Suggestion 7',
item: people[6],
isSelected: false,
showRemoveButton: true,
},
] as IFloatingSuggestionItem<IPersonaProps>[];

export const UnifiedPeoplePickerExample = (): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const getStyles = (props: IFloatingSuggestionsListStyleProps): IFloatingS
classNames.suggestionsContainer,
{
overflowX: 'auto',
overflowY: 'hidden',
overflowY: 'auto',
maxHeight: '300px',
borderBottom: `1px solid ${neutralLight}`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ exports[`UnifiedPeoplePicker renders correctly with no items 1`] = `
onMouseDownCapture={[Function]}
>
<div
className="ms-SelectionZone"
className=
ms-SelectionZone
ms-UnifiedPicker-selectionZone
ms-UnifiedPicker-selectionZone
{
display: flex;
flex: 1 1 auto;
}
onClick={[Function]}
onContextMenu={[Function]}
onDoubleClick={[Function]}
Expand Down Expand Up @@ -136,7 +143,14 @@ exports[`UnifiedPeoplePicker renders correctly with selected and suggested items
onMouseDownCapture={[Function]}
>
<div
className="ms-SelectionZone"
className=
ms-SelectionZone
ms-UnifiedPicker-selectionZone
ms-UnifiedPicker-selectionZone
{
display: flex;
flex: 1 1 auto;
}
onClick={[Function]}
onContextMenu={[Function]}
onDoubleClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export interface IUnifiedPickerStyles {
pickerText: IStyle;
pickerInput: IStyle;
pickerDiv: IStyle;
selectionZone: IStyle;
}

const GlobalClassNames = {
pickerText: 'ms-UnifiedPicker-text',
pickerInput: 'ms-UnifiedPicker-input',
pickerDiv: 'ms-UnifiedPicker-div',
selectionZone: 'ms-UnifiedPicker-selectionZone',
};

export const getStyles = (props: IUnifiedPickerStyleProps): IUnifiedPickerStyles => {
Expand Down Expand Up @@ -70,5 +72,12 @@ export const getStyles = (props: IUnifiedPickerStyleProps): IUnifiedPickerStyles
flex: '1 1 auto',
},
],
selectionZone: [
classNames.selectionZone,
{
display: 'flex',
flex: '1 1 auto',
},
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ export const UnifiedPicker = <T extends {}>(props: IUnifiedPickerProps<T>): JSX.
{...focusZoneProps}
/* TODO: create mouse drag selection capability */
>
<SelectionZone selection={selection} selectionMode={SelectionMode.multiple}>
<SelectionZone
selection={selection}
selectionMode={SelectionMode.multiple}
className={css('ms-UnifiedPicker-selectionZone', classNames.selectionZone)}
>
<div className={css('ms-BasePicker-text', classNames.pickerText)}>
{headerComponent}
{_renderSelectedItemsList()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ exports[`UnifiedPicker renders correctly with no items 1`] = `
onMouseDownCapture={[Function]}
>
<div
className="ms-SelectionZone"
className=
ms-SelectionZone
ms-UnifiedPicker-selectionZone
ms-UnifiedPicker-selectionZone
{
display: flex;
flex: 1 1 auto;
}
onClick={[Function]}
onContextMenu={[Function]}
onDoubleClick={[Function]}
Expand Down Expand Up @@ -136,7 +143,14 @@ exports[`UnifiedPicker renders correctly with selected and suggested items 1`] =
onMouseDownCapture={[Function]}
>
<div
className="ms-SelectionZone"
className=
ms-SelectionZone
ms-UnifiedPicker-selectionZone
ms-UnifiedPicker-selectionZone
{
display: flex;
flex: 1 1 auto;
}
onClick={[Function]}
onContextMenu={[Function]}
onDoubleClick={[Function]}
Expand Down
1 change: 1 addition & 0 deletions packages/react-internal/etc/react-internal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4360,6 +4360,7 @@ export interface ISelectionZone {

// @public (undocumented)
export interface ISelectionZoneProps extends React.ClassAttributes<SelectionZone> {
className?: string;
componentRef?: () => void;
disableAutoSelectOnInputElements?: boolean;
enableTouchInvocationTarget?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export interface ISelectionZoneProps extends React.ClassAttributes<SelectionZone
* item's contextual menu action occurs.
*/
onItemContextMenu?: (item?: any, index?: number, ev?: Event) => void | boolean;
/**
* Additional CSS class(es) to apply to the SelectionZone.
*/
className?: string;
}

/**
Expand Down Expand Up @@ -183,7 +187,7 @@ export class SelectionZone extends React.Component<ISelectionZoneProps, ISelecti

return (
<div
className={css('ms-SelectionZone', {
className={css('ms-SelectionZone', this.props.className, {
'ms-SelectionZone--modal': !!isModal,
})}
ref={this._root}
Expand Down

0 comments on commit 4da219b

Please sign in to comment.