Skip to content

Commit 7e734bd

Browse files
committed
ensure split menu is not cut by parent
1 parent 93f0363 commit 7e734bd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/js/dom-on-load.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function splitMenu(event) {
153153
}
154154
if (pedal && pedal !== prevPedal) {
155155
const menu = $create(SPLIT_BTN_MENU,
156+
{style: 'opacity:0'},
156157
Array.from(pedal.attributes, ({name, value}) =>
157158
name.startsWith('menu-') &&
158159
$create('a', {tabIndex: 0, __cmd: name.split('-').pop()}, value)
@@ -168,6 +169,14 @@ function splitMenu(event) {
168169
pedal.after(menu);
169170
moveFocus(menu, 0);
170171
focusA11y.toggle(menu.firstChild, focusA11y.get(pedal));
172+
new IntersectionObserver(([{
173+
intersectionRect: {width: iw},
174+
boundingClientRect: {width: cw},
175+
}], observer) => {
176+
observer.disconnect();
177+
menu.style.opacity = '';
178+
if (iw < cw) menu.style.transform = `translateX(calc(${iw - cw}px - var(--menu-pad)))`;
179+
}).observe(menu);
171180
}
172181
if (entry) {
173182
prevPedal.previousElementSibling.dispatchEvent(new CustomEvent('split-btn', {

0 commit comments

Comments
 (0)