Skip to content

Commit

Permalink
fix(Select): scroll after search by hightlight click item. Close #801
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed Jul 4, 2019
1 parent aa9de65 commit 2e31d0a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const isIE9 = env.ieVersion === 9;
/**
* 无障碍化注意事项:
* 1. Select 无搜索情况下,不应该让 Input 可focus,此时外层wrap必须可focus,并且需要相应focus事件让外边框发生变化
*
* TODO: hightLight 后续改造注意点
* 1. hightLight 跟随点击变化(fixed) 2. 弹窗打开时根据 是否高亮第一个选项的 api开关设置是否hightLight 第一项
*/

// 自定义弹层:1. 不需要关心Menu的点击事件 2. 不需要关心dataSource变化
Expand Down Expand Up @@ -351,7 +354,7 @@ class Select extends Base {
* @param {Array<string>} keys
* @
*/
handleMenuSelect(keys) {
handleMenuSelect(keys, item) {
const { mode, readOnly, disabled } = this.props;

if (readOnly || disabled) {
Expand All @@ -365,7 +368,11 @@ class Select extends Base {
return this.handleSingleSelect(keys[0], 'itemClick');
} else {
// 正常多选
return this.handleMultipleSelect(keys, 'itemClick');
return this.handleMultipleSelect(
keys,
'itemClick',
item.props && item.props._key
);
}
}

Expand Down Expand Up @@ -407,7 +414,7 @@ class Select extends Base {
/**
* 多选模式 multiple/tag
*/
handleMultipleSelect(keys, triggerType) {
handleMultipleSelect(keys, triggerType, key) {
const itemObj = getValueDataSource(
keys,
this.valueDataSource.mapValueDS,
Expand All @@ -425,6 +432,12 @@ class Select extends Base {
this.setVisible(false, triggerType);
}

key &&
this.state.visible &&
this.setState({
highlightKey: key,
});

if (this.useDetailValue()) {
this.handleChange(itemObj.valueDS, triggerType);
} else {
Expand Down

0 comments on commit 2e31d0a

Please sign in to comment.