Skip to content

Commit 64661e3

Browse files
committed
use scroll-into-view-if-needed replace dom-scroll-into-view
1 parent 151fd7d commit 64661e3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
},
4747
"dependencies": {
4848
"classnames": "2.x",
49-
"dom-scroll-into-view": "1.x",
5049
"mini-store": "^2.0.0",
5150
"rc-animate": "^2.10.1",
5251
"rc-trigger": "^4.0.0-alpha.4",
5352
"rc-util": "^4.13.0",
5453
"resize-observer-polyfill": "^1.5.0",
54+
"scroll-into-view-if-needed": "^2.2.20",
5555
"shallowequal": "^1.1.0"
5656
},
5757
"devDependencies": {

src/MenuItem.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import KeyCode from 'rc-util/lib/KeyCode';
44
import classNames from 'classnames';
5-
import scrollIntoView from 'dom-scroll-into-view';
5+
import scrollIntoView from 'scroll-into-view-if-needed';
66
import { connect } from 'mini-store';
77
import { noop, menuAllProps } from './util';
88
import {
@@ -76,8 +76,9 @@ export class MenuItem extends React.Component<MenuItemProps> {
7676
(!parentMenu || !parentMenu[`scrolled-${eventKey}`])
7777
) {
7878
if (this.node) {
79-
scrollIntoView(this.node, ReactDOM.findDOMNode(parentMenu), {
80-
onlyScrollIfNeeded: true,
79+
scrollIntoView(this.node, {
80+
scrollMode: 'if-needed',
81+
boundary: ReactDOM.findDOMNode(parentMenu) as Element,
8182
});
8283
parentMenu[`scrolled-${eventKey}`] = true;
8384
}

0 commit comments

Comments
 (0)