From 0bcd3eab8612dfc652fcaef61346db42cf2c8505 Mon Sep 17 00:00:00 2001 From: atomiks Date: Sat, 6 Jun 2020 18:19:30 +1000 Subject: [PATCH] fix: #1124 --- src/dom-utils/getOffsetParent.js | 7 ++- ...d-position-popper-on-right-1124-1-snap.png | Bin 0 -> 3350 bytes tests/functional/table.test.js | 9 ++- tests/visual/table/offset-parent-2.html | 52 ++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 tests/functional/__image_snapshots__/table-test-js-should-position-popper-on-right-1124-1-snap.png create mode 100644 tests/visual/table/offset-parent-2.html 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 0000000000000000000000000000000000000000..5ea28a8915a1ab9197c43710d288e993c08f9bed GIT binary patch literal 3350 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYV2a>i1B%QlYbpRzjKx9jP7LeL$-HD>;JM)G z;uumf=j|;=FBL}-*NYr0Wp}E_PTspb?sB;n$1j3kUvI7G{Lk|NZ1A`G03j@Om4uMg@kq{u8)6@3Z+^DXtWZ=)5FLyv)e7-Tm z1N#DNTZVTt<>MF{=6_@X7PlicIc$F~^R|93uu7@mn9gWqe3XxY;Q?bs6YFRlGg|46 pHaJEbTcZul5!BEmzJu{h*6)qNhVml2zrZdDgQu&X%Q~loCIGO;!mI!Q literal 0 HcmV?d00001 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
+
+ +