Atlaskit Dropdown Menu can't select item

Hi all,
I would like to add a dropdown menu to my project using atlaskit libraries. In order to see how it works, I’ve basically copied the stateless dropdown menu example from atlaskit web page. I’m using react with typescript in my project. After adding the example code, which I’ll share below, dropdown menu is added to my example html file. When I click the dropdown button the menu opens but when I try to select an item menu closes itself and no item is selected. The code is like below:

Dropdown.tsx:

import * as React from 'react';
import {
    DropdownMenuStateless,
    DropdownItemGroupRadio,
    DropdownItemRadio,
} from '@atlaskit/dropdown-menu';

type State = {
    isDropdownOpen: boolean,
};

export default class StatelessMenuExample extends React.Component<{}, State> {
    state = { isDropdownOpen: false };

    render() {
        return (
            <div>
                <DropdownMenuStateless
                    isOpen={this.state.isDropdownOpen}
                    onOpenChange={attrs => {
                        this.setState({ isDropdownOpen: attrs.isOpen });
                    }}
                    trigger="Choose"
                    triggerType="button"
                    isMenuFixed
                >
                    <DropdownItemGroupRadio id="cities">
                        <DropdownItemRadio id="sydney">Sydney</DropdownItemRadio>
                        <DropdownItemRadio id="melbourne">Melbourne</DropdownItemRadio>
                    </DropdownItemGroupRadio>
                </DropdownMenuStateless>
            </div>
        );
    }
}

Index.tsx:

import * as React from "react";
import * as ReactDOM from "react-dom";

import StatelessMenuExample from "./Dropdown";

import { Graph } from "./modules/graph/Graph";

import axios from 'axios';

declare const AP: any;

ReactDOM.render(
    <StatelessMenuExample/>,
    document.getElementById("filter_dropdown")
);

Any ideas about this problem, what am I doing wrong? Thanks in advance… :slight_smile:

Did you ever find a solution to this issue?

Not yet, unfortunately…

I had the same problem. It was due to version of styled-components in package.json. Once I downgraded it from 4.4.1 to 3.2.6, it was fixed.

3 Likes

Thank you for your response, when I try, I’ll let you know whether it worked for me or not.

I had the same error, it’s work when you change the version (3.2.6) :grinning:

Even today (23/11/2020), I still have to downgrade the styled-component to 3.2.6 in order to work with dropdown!