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 ComboBox, ContextualMenu, Teachingbubble overwriting calloutProps.className",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,20 @@ describe('ComboBox', () => {
wrapper.update();
expect(wrapper.find('.ms-ComboBox input').props().value).toEqual('Text');
});

it('merges callout classNames', () => {
ReactTestUtils.renderIntoDocument<ComboBox>(
<ComboBox
options={ DEFAULT_OPTIONS }
calloutProps={ { className: 'foo' } }
/>
);

setTimeout(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setTimeout is needed due to the calloutProps not being fully propagated on first UI tick. Please let me know if there is a better solution to solve that problem.

let callout = document.querySelector('.ms-Callout') as HTMLElement;
expect(callout).toBeDefined();
expect(callout.classList.contains('ms-ComboBox-callout')).toBeTruthy();
expect(callout.classList.contains('foo')).toBeTruthy();
}, 0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
getId,
getNativeProps,
KeyCodes,
customizable
customizable,
css
} from '../../Utilities';
import { SelectableOptionMenuItemType, ISelectableOption } from '../../utilities/selectableOption/SelectableOption.types';
import {
Expand Down Expand Up @@ -867,7 +868,7 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> {
directionalHint={ DirectionalHint.bottomLeftEdge }
directionalHintFixed={ true }
{ ...calloutProps }
className={ this._classNames.callout }
className={ css(this._classNames.callout, calloutProps ? calloutProps.className : undefined) }
target={ this._comboBoxWrapper }
onDismiss={ this._onDismiss }
onScroll={ this._onScroll }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,23 @@ describe('ContextualMenu', () => {
expect(menuMountedFirst).toEqual(false);
});

it('merges callout classNames', () => {
ReactTestUtils.renderIntoDocument<ContextualMenu>(
<ContextualMenu
items={ [{
name: 'TestText 0',
key: 'TestKey0'
}] }
calloutProps={ { className: 'foo' } }
/>
);

let callout = document.querySelector('.ms-Callout') as HTMLElement;
expect(callout).toBeDefined();
expect(callout.classList.contains('ms-ContextualMenu-Callout')).toBeTruthy();
expect(callout.classList.contains('foo')).toBeTruthy();
});

it('Contextual Menu submenu has chrevron icon even if submenu has no items', () => {
const menuWithEmptySubMenu: IContextualMenuItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
getWindow,
customizable,
getFirstFocusable,
getLastFocusable
getLastFocusable,
css
} from '../../Utilities';
import { withResponsiveMode, ResponsiveMode } from '../../utilities/decorators/withResponsiveMode';
import { Callout } from '../../Callout';
Expand Down Expand Up @@ -280,7 +281,7 @@ export class ContextualMenu extends BaseComponent<IContextualMenuProps, IContext
gapSpace={ gapSpace }
coverTarget={ coverTarget }
doNotLayer={ doNotLayer }
className='ms-ContextualMenu-Callout'
className={ css('ms-ContextualMenu-Callout', calloutProps ? calloutProps.className : undefined) }
setInitialFocus={ shouldFocusOnMount }
onDismiss={ this.props.onDismiss }
onScroll={ this._onScroll }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,18 @@ describe('TeachingBubble', () => {
expect(titleElement!.textContent).toEqual('Title');
});

it('merges callout classNames', () => {
ReactTestUtils.renderIntoDocument<TeachingBubbleContent>(
<TeachingBubbleContent
headline='Title'
calloutProps={ { className: 'foo' } }
/>
);
setTimeout(() => {
let callout = document.querySelector('.ms-Callout') as HTMLElement;
expect(callout).toBeDefined();
expect(callout.classList.contains('ms-TeachingBubble')).toBeTruthy();
expect(callout.classList.contains('foo')).toBeTruthy();
}, 0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export class TeachingBubble extends BaseComponent<ITeachingBubbleProps, ITeachin

return (
<Callout
className={ css('ms-TeachingBubble', styles.root, this.props.isWide ? styles.wideCallout : null) }
ref={ this._resolveRef('_callout') }
target={ targetElement }
{...calloutProps}
className={ css('ms-TeachingBubble', styles.root, this.props.isWide ? styles.wideCallout : null, calloutProps ? calloutProps.className : undefined) }
>
<TeachingBubbleContent { ...this.props } />
</Callout>
Expand Down