Skip to content

Commit

Permalink
wip: set horizontal width more correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Apr 25, 2024
1 parent 275cd8d commit 969fe23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/Menu/src/item.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
let itemEls: HTMLElement[] | null = null;
let prevParentDomWidth = -1;
let ops = Array(items.length).fill(level === 1 ? '0' : '1');
let widths = Array(items.length).fill(level === 1 ? 'auto' : '100%');
let moreItems: Array<{
item: SubMenuType;
width: number;
Expand Down Expand Up @@ -289,7 +290,7 @@
(child as HTMLElement).style.overflowY = 'hidden';
(child as HTMLElement).style.position = 'absolute';
(child as HTMLElement).style.pointerEvents = 'none';
(child as HTMLElement).style.width = '0';
widths[index] = '0';
if (popoverRef[index] && itemsList[index].open) {
popoverRef[index] &&
popoverRef[index].updateShow &&
Expand Down Expand Up @@ -323,12 +324,11 @@
const dom = itemEls![index];
if (dom) {
(dom as HTMLElement).style.opacity = '1';
(dom as HTMLElement).style.width = '100';
(dom as HTMLElement).style.removeProperty('height');
(dom as HTMLElement).style.removeProperty('overflow-y');
(dom as HTMLElement).style.removeProperty('position');
(dom as HTMLElement).style.removeProperty('pointer-events');
(dom as HTMLElement).style.removeProperty('width');
widths[index] = 'auto';
hiddenIndex.delete(index);
if (popoverRef[index] && itemsList[index].open) {
isDirty = true;
Expand Down Expand Up @@ -606,7 +606,7 @@
<KPopover
bind:this={popoverRef[index]}
attrsTrigger={{ 'data-k-menu-h': `${level}` }}
width="100%"
width={widths[index]}
order={index}
arrow={false}
opacity={ops[index]}
Expand Down

0 comments on commit 969fe23

Please sign in to comment.