fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

CommandBar: Using new commands with old fabric-core causes missing font icons

Open TBag opened this issue 10 years ago • 10 comments

Issue: Implement a command bar that includes child items and view it in the Google Chrome browser. Notice the empty boxes that appear next to the top level items in the command bar. This issue does not occur in IE, Edge, or FireFox.

Expected behavior: The Empty box does not appear in the Google Chrome browser.

Code to replicate issue:

const commandBarItems = this._generateCommandBarItems();

public render(): JSX.Element {
return (
      <div className={styles.opportunityTracker}>
        <div className={styles.container}>
          {/* filter bar */}
          <div className="ms-Grid-row">
            <div className="ms-Grid-col ms-u-sm12">
              <CommandBar
                isSearchBoxVisible={ false }
                searchPlaceholderText='Search...'
                elipisisAriaLabel='More options'
                items={ this.state["commandBarItems"] }
                />
            </div>
          </div>

private _generateCommandBarItems(): Array{
const contextualMenuItems: Array = [];

//Sort
contextualMenuItems.push({
  key: 'Sort',
  name: 'Sort',
  icon: 'sortLines',
  onClick: (item: IContextualMenuItem, ev: React.MouseEvent) : void => {ev.preventDefault();},
  items: [
    {
        key: 'ALPHABETICAL',
        name: 'ALPHABETICAL',
        onClick: (item: IContextualMenuItem, ev: React.MouseEvent) : void => {
          this.setState({
            //replace setting the state with react add-ons update
            //npm i react-addons-update
            //let update = require{'react-addons-update'};
            opportunities: this._sortAndFilterOpportunities(item.key, this.state["statusSelectedKey"], this.state["ownerSelectedKey"]),
            sortedBySelectedKey: item.key
          });
          ev.preventDefault();
        }
    },
    {
        key: 'FORECAST DATE',
        name: 'FORECAST DATE',
        onClick: (item: IContextualMenuItem, ev: React.MouseEvent) : void => {
          this.setState({
            opportunities: this._sortAndFilterOpportunities(item.key, this.state["statusSelectedKey"], this.state["ownerSelectedKey"]),
            sortedBySelectedKey: item.key
          });
          ev.preventDefault();
        },
        isChecked: true
    }
  ]
});

Style to add to fix issue:

.commandBar i{
display: none;
}
command bar empty box

TBag avatar Oct 05 '16 14:10 TBag

Hey @TBag what version of fabric core css are you using on your page? This seems like a compat issue with the font icon rather than the command bar. Can you update the fabric core css?

dzearing avatar Oct 06 '16 05:10 dzearing

@dzearing Upgraded to 4.0.0.0 yesterday and I still see the empty boxes in Google Chrome.

empty boxes

TBag avatar Oct 07 '16 11:10 TBag

@Jahnp can you provide instructions here on using the old chevron icon set with new controls (just need the CSS snippet) and then close this issue?

dzearing avatar Oct 27 '16 16:10 dzearing

Sure. @TBag, I'm assuming from the screenshots that you're using the icons from before Fabric-Core 4.0.

In this case, the general gist is to map the Unicode values from the old Fabric icon set to the new icon class names. This looks something like this:

.ms-Icon--Sort::before { content: '\e085'; } // The value for content here is the Unicode value from the old .ms-Icon--sort

Please let us know if this helps resolve your issue here!

Jahnp avatar Oct 27 '16 16:10 Jahnp

I think he’s talking about the missing down chevrons. I think that's a different code.

dzearing avatar Oct 27 '16 16:10 dzearing

I dug around the pre-mdl2 code and see "ms-Icon--chevronDown" is probably the missing one, replaced with ms-Icon--ChevronDown

dzearing avatar Oct 27 '16 16:10 dzearing

Yes--I was explaining the general technique of mapping old icons to new names since the screenshot isn't using the new icons. @TBag did you intend to use the new icons or the old icons? If you want to use the old icons with the new markup, it'd be something like:

.ms-Icon--ChevronDown::before { content: '\e088'; }

Jahnp avatar Oct 27 '16 17:10 Jahnp

@dzearing Yes, that is the missing icon. @Jahnp Thanks for your suggestions on how we can fix this. We have not had time to test it out but it's on our list. I'll let you know as soon as we try it out.

TBag avatar Oct 27 '16 18:10 TBag

@TBag I would like to close this issue. If you have a bug or feature request, please feel free to re-open.

dzearing avatar Nov 07 '16 19:11 dzearing

@dzearing We have not had time to test it out but it's on our list. I'll let you know as soon as we try it out.

TBag avatar Nov 07 '16 19:11 TBag