1

I created a create-react-app project on my machine.

I ran npm i @fluentui/react in my project directory terminal to install the fluent ui package.

I have simple code to display a dropdown, with all the correct imports

import { Dropdown, DropdownMenuItemType, IDropdownStyles, IDropdownOption } from '@fluentui/react/lib/Dropdown';

const dropdownStyles: Partial<IDropdownStyles> = {
  dropdown: { width: 300 },
};

const options: IDropdownOption[] = [
  { key: 'fruitsHeader', text: 'Fruits', itemType: DropdownMenuItemType.Header },
  { key: 'apple', text: 'Apple' },
  { key: 'banana', text: 'Banana' },
  { key: 'orange', text: 'Orange', disabled: true },
  { key: 'grape', text: 'Grape' },
  { key: 'divider_1', text: '-', itemType: DropdownMenuItemType.Divider },
  { key: 'vegetablesHeader', text: 'Vegetables', itemType: DropdownMenuItemType.Header },
  { key: 'broccoli', text: 'Broccoli' },
  { key: 'carrot', text: 'Carrot' },
  { key: 'lettuce', text: 'Lettuce' },
];

function App() {
  return (
    <div className="App">
     <Dropdown
        placeholder="Select an option"
        options={options}
        styles={dropdownStyles}
      />
    </div>
  );
}

What is getting displayed is a weird box with no clickable dropdown. enter image description here

I did some research and I needed to import the icons so I added such code to my project.

import { initializeIcons } from "@fluentui/react/lib/Icons";

initializeIcons();

Now the dropdown displays the correct icon however nothing happens onclick of the icon. enter image description here

Weirdly enough, when the screen size is tablet sized the dropdown will show up as context pane but will not appear in full screen mode enter image description here

Ive searched SO and haven't found any answers to this. Any help would be appreciated!

Cameron
  • 185
  • 2
  • 11

2 Answers2

0

If I understand well you want to disable responsive mode:

import { ResponsiveMode } from '@fluentui/react'

<Dropdown
  ...
  responsiveMode={ResponsiveMode.unknown}
/>

Codepen working example.

Marko Savic
  • 2,159
  • 2
  • 14
  • 27
0

If you have <React.StrictMode> in your index.tsx, you can remove this and then it works (at least for me when I was having the same issue).

CMorgan
  • 645
  • 2
  • 11
  • 33