Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Dropdown Example #16040

Closed
zakalwe2016 opened this issue Jun 7, 2019 · 2 comments
Closed

Simple Dropdown Example #16040

zakalwe2016 opened this issue Jun 7, 2019 · 2 comments
Labels
[Package] Components /packages/components [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@zakalwe2016
Copy link

zakalwe2016 commented Jun 7, 2019

I have created a simple block to experiment with the Dropdown component as detailed at https://developer.wordpress.org/block-editor/components/dropdown/

My block is defined as follows:

const {
    registerBlockType
} = wp.blocks;

import {
    Dropdown,
    Button
} from '@wordpress/components';

registerBlockType('test/test', {
    title: 'Test',
    description: 'Test Block',
    category: 'layout',
    edit(props) {

        const MyDropdown = () => (
            <Dropdown
                className="my-container-class-name"
                contentClassName="my-popover-content-classname"
                position="top center"
                renderToggle={ ( { isOpen, onToggle } ) => (
                    <Button isPrimary onClick={ onToggle } aria-expanded={ isOpen }>
                        Toggle Popover!
                    </Button>
                ) }
                renderContent={ () => (
                    <div>
                        This is the content of the popover.
                    </div>
                ) }
            />
        );

        return (
            <MyDropdown/>
        );

    },
    save(props) {}
});

The error that results is:

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of PopoverDetectOutside which is inside StrictMode. Instead, add a ref directly to the element you want to reference.

I also note that the location of the popover is not aligned to the dropdown, I can see in the rendered html that the containing block is a div so spans the width of the container.

image

Any help would be greatly appreciated. Still a bit green around the gills when it comes to React and Gutenberg but I'm learning!

@swissspidy swissspidy added [Type] Help Request Help with setup, implementation, or "How do I?" questions. [Package] Components /packages/components labels Jun 7, 2019
@zakalwe2016
Copy link
Author

#8468 is possibly related as issue seems extremely similar in nature

@youknowriad
Copy link
Contributor

That's just a React Warning which shouldn't break anything. We removed all those deprecated APIs usage in the last versions but some plugins may still use them which would result in that message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants