修复tree模式鼠标hover无背景
This commit is contained in:
parent
79601008cf
commit
72181f249c
2
dist/static/2.js
vendored
2
dist/static/2.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xm-select.js
vendored
2
dist/xm-select.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,8 @@
|
||||
import { h, Component, render } from 'preact'
|
||||
import { deepMerge, isFunction } from '@/common/util'
|
||||
|
||||
const emptyVal = {};
|
||||
|
||||
class Tree extends Component{
|
||||
|
||||
constructor(options){
|
||||
@ -9,6 +11,7 @@ class Tree extends Component{
|
||||
this.state = {
|
||||
expandedKeys: [],
|
||||
filterValue: '',
|
||||
val: emptyVal,
|
||||
}
|
||||
|
||||
this.searchCid = 0;
|
||||
@ -155,7 +158,7 @@ class Tree extends Component{
|
||||
if(this.props.show != props.show){
|
||||
if(!props.show){
|
||||
//清空输入框的值
|
||||
this.setState({ filterValue: '' });
|
||||
this.setState({ filterValue: '', val: emptyVal });
|
||||
this.__value = '';
|
||||
this.searchInputRef && (this.searchInputRef.value = '');
|
||||
}else{
|
||||
@ -215,8 +218,23 @@ class Tree extends Component{
|
||||
}
|
||||
}
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
}
|
||||
//处理鼠标选择的背景色
|
||||
const hoverChange = e => {
|
||||
if(e.type === 'mouseenter'){
|
||||
if(!item[disabled]){
|
||||
this.setState({ val: item[value] })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={ className } style={ itemStyle } value={ item[value] } onClick={ this.optionClick.bind(this, item, selected, item[disabled], 'line') }>
|
||||
<div class={ className } style={ itemStyle } value={ item[value] } onClick={
|
||||
this.optionClick.bind(this, item, selected, item[disabled], 'line')
|
||||
} onMouseEnter={ hoverChange } onMouseLeave={ hoverChange }>
|
||||
{ iconArray }
|
||||
{ item.__node.loading && <span class="loader"></span> }
|
||||
{ showIcon && <i class={ iconClass } style={ iconStyle } onClick={ this.optionClick.bind(this, item, selected, item[disabled], 'checkbox') }></i> }
|
||||
|
Loading…
Reference in New Issue
Block a user