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

fix: #1124 #1125

Merged
merged 1 commit into from Jun 6, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/dom-utils/getOffsetParent.js
Expand Up @@ -26,8 +26,11 @@ export default function getOffsetParent(element: Element) {

let offsetParent = getTrueOffsetParent(element);

// Find the nearest non-table offsetParent
while (offsetParent && isTableElement(offsetParent)) {
while (
offsetParent &&
isTableElement(offsetParent) &&
getComputedStyle(offsetParent).position === 'static'
) {
offsetParent = getTrueOffsetParent(offsetParent);
}

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion tests/functional/table.test.js
Expand Up @@ -4,7 +4,7 @@
*/
import { screenshot, scroll } from '../utils/puppeteer.js';

const hack = async page => {
const hack = async (page) => {
// HACK: fixes issue with tables on GitHub Actions
if (Boolean(process.env.CI)) {
await page.addStyleTag({ content: 'table { margin-left: 4px; }' });
Expand Down Expand Up @@ -50,3 +50,10 @@ it('should position popper on right when reference and popper are in table insid

expect(await screenshot(page)).toMatchImageSnapshot();
});

it('should position popper on right #1124', async () => {
const page = await browser.newPage();
await page.goto(`${TEST_URL}/table/offset-parent-2.html`);

expect(await screenshot(page)).toMatchImageSnapshot();
});
52 changes: 52 additions & 0 deletions tests/visual/table/offset-parent-2.html
@@ -0,0 +1,52 @@
<!DOCTYPE html> <title>Basic Visual Test</title>

<style>
@import '/reset.css';
html,
body {
height: 1500px;
}

#reference {
width: 200px;
height: 200px;
background-color: red;
box-shadow: inset 0 0 0 1px black;
}

#popper {
width: 100px;
height: 100px;
background-color: rebeccapurple;
box-shadow: inset 0 0 0 1px black;
}

table {
margin-top: 100px;
}

th {
position: relative;
}
</style>

<table>
<tbody>
<tr>
<th>
<div id="reference">Reference</div>
<div id="popper">Popper</div>
</th>
</tr>
</tbody>
</table>

<script type="module">
import { createPopper } from '../dist/popper.js';
const reference = document.querySelector('#reference');
const popper = document.querySelector('#popper');

window.instance = createPopper(reference, popper, {
placement: 'right',
});
</script>