Skip to content

Commit

Permalink
refactor: rename onDropdownScroll to onPopupScroll
Browse files Browse the repository at this point in the history
  • Loading branch information
OysterD3 committed Nov 26, 2024
1 parent bc6f099 commit a00c7ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/examples/onScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default () => (
<Mentions
rows={3}
defaultValue="Hello @ World @"
onDropdownScroll={console.log}
onPopupScroll={console.log}
dropdownClassName="on-scroll"
open
options={Array.from({ length: 1000 }).map((_, index) => ({
Expand Down
6 changes: 3 additions & 3 deletions src/Mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>,
containerHeight: number,
currentOffset: number,
Expand Down Expand Up @@ -141,7 +141,7 @@ const InternalMentions = forwardRef<MentionsRef, MentionsProps>(
// https://github.com/ant-design/ant-design/blob/df933e94efc8f376003bbdc658d64b64a0e53495/components/mentions/demo/render-panel.tsx
// @ts-expect-error
visible,
onDropdownScroll,
onPopupScroll,

// Rest
...restProps
Expand Down Expand Up @@ -473,7 +473,7 @@ const InternalMentions = forwardRef<MentionsRef, MentionsProps>(
const containerHeight = currentTarget.getBoundingClientRect().height;
const currentOffset = currentTarget.scrollTop;

onDropdownScroll?.(event, containerHeight, currentOffset);
onPopupScroll?.(event, containerHeight, currentOffset);
};

// ============================== Render ==============================
Expand Down
8 changes: 4 additions & 4 deletions tests/Mentions.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit a00c7ac

Please sign in to comment.