From a00c7ac9f3ff918a144b552482efd7cd19ad1a87 Mon Sep 17 00:00:00 2001 From: Oyster Lee Date: Tue, 26 Nov 2024 11:08:48 +0800 Subject: [PATCH] refactor: rename onDropdownScroll to onPopupScroll --- docs/examples/onScroll.tsx | 2 +- src/Mentions.tsx | 6 +++--- tests/Mentions.spec.tsx | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/examples/onScroll.tsx b/docs/examples/onScroll.tsx index c85b22a..21c6da2 100644 --- a/docs/examples/onScroll.tsx +++ b/docs/examples/onScroll.tsx @@ -7,7 +7,7 @@ export default () => ( ({ diff --git a/src/Mentions.tsx b/src/Mentions.tsx index 99e4a6f..b6e72dc 100644 --- a/src/Mentions.tsx +++ b/src/Mentions.tsx @@ -78,7 +78,7 @@ export interface MentionsProps extends BaseTextareaAttrs { * @param containerHeight The height of the mentions container * @param currentOffset The current scroll offset */ - onDropdownScroll?: ( + onPopupScroll?: ( event: React.UIEvent, containerHeight: number, currentOffset: number, @@ -141,7 +141,7 @@ const InternalMentions = forwardRef( // https://github.com/ant-design/ant-design/blob/df933e94efc8f376003bbdc658d64b64a0e53495/components/mentions/demo/render-panel.tsx // @ts-expect-error visible, - onDropdownScroll, + onPopupScroll, // Rest ...restProps @@ -473,7 +473,7 @@ const InternalMentions = forwardRef( const containerHeight = currentTarget.getBoundingClientRect().height; const currentOffset = currentTarget.scrollTop; - onDropdownScroll?.(event, containerHeight, currentOffset); + onPopupScroll?.(event, containerHeight, currentOffset); }; // ============================== Render ============================== diff --git a/tests/Mentions.spec.tsx b/tests/Mentions.spec.tsx index 68e633a..2c60d60 100644 --- a/tests/Mentions.spec.tsx +++ b/tests/Mentions.spec.tsx @@ -300,15 +300,15 @@ describe('Mentions', () => { expect(container.firstChild).toHaveClass('rc-mentions-disabled'); }); - it('onDropdownScroll should work', () => { - const onDropdownScroll = jest.fn(); - const { container, baseElement } = renderMentions({ onDropdownScroll }); + it('onPopupScroll should work', () => { + const onPopupScroll = jest.fn(); + const { container, baseElement } = renderMentions({ onPopupScroll }); simulateInput(container, '@'); act(() => { jest.runAllTimers(); }); fireEvent.scroll(baseElement.querySelector('.rc-mentions-dropdown-menu')); - expect(onDropdownScroll).toHaveBeenCalled(); + expect(onPopupScroll).toHaveBeenCalled(); }); describe('nativeElement', () => {