diff --git a/src/dom-utils/getOffsetParent.js b/src/dom-utils/getOffsetParent.js index 513793f7a8..31be4234fa 100644 --- a/src/dom-utils/getOffsetParent.js +++ b/src/dom-utils/getOffsetParent.js @@ -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); } diff --git a/tests/functional/__image_snapshots__/table-test-js-should-position-popper-on-right-1124-1-snap.png b/tests/functional/__image_snapshots__/table-test-js-should-position-popper-on-right-1124-1-snap.png new file mode 100644 index 0000000000..5ea28a8915 Binary files /dev/null and b/tests/functional/__image_snapshots__/table-test-js-should-position-popper-on-right-1124-1-snap.png differ diff --git a/tests/functional/table.test.js b/tests/functional/table.test.js index 6232fe19b2..f80364bf5a 100644 --- a/tests/functional/table.test.js +++ b/tests/functional/table.test.js @@ -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; }' }); @@ -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(); +}); diff --git a/tests/visual/table/offset-parent-2.html b/tests/visual/table/offset-parent-2.html new file mode 100644 index 0000000000..eadcd1f353 --- /dev/null +++ b/tests/visual/table/offset-parent-2.html @@ -0,0 +1,52 @@ + Basic Visual Test + + + + + + + + + +
+
Reference
+
Popper
+
+ +