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

Dropdown: Popover content is wrong positioned #8559

Closed
mmtr opened this issue Aug 5, 2018 · 3 comments · Fixed by #18631
Closed

Dropdown: Popover content is wrong positioned #8559

mmtr opened this issue Aug 5, 2018 · 3 comments · Fixed by #18631
Assignees
Labels
[Feature] UI Components Impacts or related to the UI component system Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@mmtr
Copy link
Contributor

mmtr commented Aug 5, 2018

Describe the bug
When rendering a Dropdown component outside Gutenberg, the popover content is wrong positioned.

To Reproduce
Execute the code below in a new React project after installing @wordpress/components.

import React from 'react';
import ReactDOM from 'react-dom';
import { Button, Dropdown } from '@wordpress/components';

import '@wordpress/components/build-style/styles.css';

const MyDropdown = () => (
	<Dropdown
		position="bottom right"
		renderToggle={ ( { isOpen, onToggle } ) => (
			<Button isPrimary onClick={ onToggle } aria-expanded={ isOpen }>
				Toggle Popover!
			</Button>
		) }
		renderContent={ () => (
			<div>
				This is the content of the popover.
			</div>
		) }
	/>
);

ReactDOM.render(
	<MyDropdown />,
	document.getElementById( 'root' )
);

Expected behavior
The popover content should be displayed below the button.

Screenshots
screen shot 2018-08-05 at 22 49 24

Desktop:

  • OS: macOS High Sierra
  • Browser Chrome
  • Version 67

Additional context
Issue found while working on #8338 and Automattic/wp-calypso#26367

@gziolo gziolo added [Type] Bug An existing feature does not function as intended [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels Aug 6, 2018
@youknowriad
Copy link
Contributor

I'm not certain this is an issue.

In this particular example if you give a className to the dropdown component and display it as an "inline-block" it will show up properly. The idea is that the popover shows up centered within the Dropdown component's container.

Should we make the dropdown's container always inline-block by default? Maybe, but we should be careful about the consequences.

@youknowriad youknowriad added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Dec 25, 2018
@gziolo gziolo added the Needs Dev Ready for, and needs developer efforts label Apr 10, 2019
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 20, 2019
@rmorse
Copy link
Contributor

rmorse commented Feb 19, 2021

In case it helps anyone, I've been having some similar issues with this, and the color picker tooltips in standalone React apps.

If you are making applications outside of Block Editor and want to use these features, make sure to add a

<SlotFillProvider /> and a <Popopver.Slot />

So your app could look something like this:

<SlotFillProvider>
	<YourApp />
	<Popover.Slot />
</SlotFillProvider>

@dlxsnippets
Copy link

If you are making applications outside of Block Editor and want to use these features, make sure to add a

<SlotFillProvider /> and a <Popopver.Slot />

So your app could look something like this:

<SlotFillProvider>
	<YourApp />
	<Popover.Slot />
</SlotFillProvider>

@rmorse This is AMAZING. I've been debugging this now for a few hours and you got it on the nose. Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
5 participants