Skip to content

Commit fe0f5ef

Browse files
zombieJclaude
andcommitted
fix: correct stack offset calculation in useListPosition
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c65ca1e commit fe0f5ef

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/hooks/useListPosition/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ export default function useListPosition(configList: { key: React.Key }[], stack?
1818
const key = String(config.key);
1919
const nodePosition = {
2020
x: 0,
21-
y: stack ? offsetY + (stack.offset ?? 0) : offsetY,
21+
y: offsetY,
2222
};
2323

2424
nextNotificationPosition.set(key, nodePosition);
25-
offsetY += sizeMap[key]?.height ?? 0;
25+
// offsetY += (sizeMap[key]?.height ?? 0) + (stack?.offset ?? 0);
26+
offsetY += (stack ? stack.offset : sizeMap[key]?.height) ?? 0;
2627
});
2728

2829
return nextNotificationPosition;

tests/stack.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ describe('stack', () => {
113113
fireEvent.click(container.querySelector('button'));
114114
}
115115

116-
const [firstNotice] = document.querySelectorAll<HTMLElement>('.rc-notification-notice');
116+
const notices = Array.from(document.querySelectorAll<HTMLElement>('.rc-notification-notice'));
117+
const offsetList = notices.map((notice) => notice.style.getPropertyValue('--notification-y'));
117118

118-
expect(firstNotice.style.getPropertyValue('--notification-y')).toBe('12px');
119+
expect(offsetList).toContain('0px');
120+
expect(offsetList).toContain('12px');
119121

120122
fireEvent.mouseEnter(document.querySelector('.rc-notification-list'));
121123

122-
expect(firstNotice.style.getPropertyValue('--notification-y')).toBe('0px');
124+
expect(
125+
notices.every((notice) => notice.style.getPropertyValue('--notification-y') === '0px'),
126+
).toBeTruthy();
123127
});
124128
});

0 commit comments

Comments
 (0)