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

Better guarantee that a popover position can be found #2948

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

- Fixed `EuiTitle` not rendering child classes ([#2925](https://github.com/elastic/eui/pull/2925))
- Extended `div` element in `EuiFlyout` type ([#2914](https://github.com/elastic/eui/pull/2914))
- Fixed popover positioning service to be more lenient when positioning 0-width or 0-height content ([#2948](https://github.com/elastic/eui/pull/2948))

**Theme: Amsterdam**

Expand Down
43 changes: 43 additions & 0 deletions src/components/flyout/__snapshots__/flyout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,49 @@ exports[`EuiFlyout max width can be set to a default 1`] = `
</div>
`;

exports[`EuiFlyout props accepts div props 1`] = `
<div>
<div
data-focus-guard="true"
style="width:1px;height:0px;padding:0;overflow:hidden;position:fixed;top:1px;left:1px"
tabindex="0"
/>
<div
data-focus-guard="true"
style="width:1px;height:0px;padding:0;overflow:hidden;position:fixed;top:1px;left:1px"
tabindex="1"
/>
<div
data-focus-lock-disabled="false"
>
<div
class="euiFlyout euiFlyout--medium"
id="imaflyout"
role="dialog"
tabindex="0"
>
<button
aria-label="Closes this dialog"
class="euiButtonIcon euiButtonIcon--text euiFlyout__closeButton"
data-test-subj="euiFlyoutCloseButton"
type="button"
>
<div
aria-hidden="true"
class="euiButtonIcon__icon"
data-euiicon-type="cross"
/>
</button>
</div>
</div>
<div
data-focus-guard="true"
style="width:1px;height:0px;padding:0;overflow:hidden;position:fixed;top:1px;left:1px"
tabindex="0"
/>
</div>
`;

exports[`EuiFlyout props close button is not rendered 1`] = `
<div>
<div
Expand Down
4 changes: 2 additions & 2 deletions src/services/popover/popover_positioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function findPopoverPosition({
}
}

let bestFit = -Infinity;
let bestFit: number | undefined = undefined;
let bestPosition: FindPopoverPositionResult | null = null;

for (let idx = 0; idx < iterationPositions.length; idx++) {
Expand All @@ -201,7 +201,7 @@ export function findPopoverPosition({
arrowConfig,
});

if (screenCoordinates.fit > bestFit) {
if (bestFit === undefined || screenCoordinates.fit > bestFit) {
bestFit = screenCoordinates.fit;
bestPosition = {
fit: screenCoordinates.fit,
Expand Down