修复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 { h, Component, render } from 'preact'
|
||||||
import { deepMerge, isFunction } from '@/common/util'
|
import { deepMerge, isFunction } from '@/common/util'
|
||||||
|
|
||||||
|
const emptyVal = {};
|
||||||
|
|
||||||
class Tree extends Component{
|
class Tree extends Component{
|
||||||
|
|
||||||
constructor(options){
|
constructor(options){
|
||||||
@ -9,6 +11,7 @@ class Tree extends Component{
|
|||||||
this.state = {
|
this.state = {
|
||||||
expandedKeys: [],
|
expandedKeys: [],
|
||||||
filterValue: '',
|
filterValue: '',
|
||||||
|
val: emptyVal,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.searchCid = 0;
|
this.searchCid = 0;
|
||||||
@ -155,7 +158,7 @@ class Tree extends Component{
|
|||||||
if(this.props.show != props.show){
|
if(this.props.show != props.show){
|
||||||
if(!props.show){
|
if(!props.show){
|
||||||
//清空输入框的值
|
//清空输入框的值
|
||||||
this.setState({ filterValue: '' });
|
this.setState({ filterValue: '', val: emptyVal });
|
||||||
this.__value = '';
|
this.__value = '';
|
||||||
this.searchInputRef && (this.searchInputRef.value = '');
|
this.searchInputRef && (this.searchInputRef.value = '');
|
||||||
}else{
|
}else{
|
||||||
@ -214,9 +217,24 @@ class Tree extends Component{
|
|||||||
iconArray.push(<i class='top-line' style={ { left: indent - tree.indent + 3 + 'px', width: tree.indent + (expand === 0 ? 10 : -2) + 'px' } }></i>);
|
iconArray.push(<i class='top-line' style={ { left: indent - tree.indent + 3 + 'px', width: tree.indent + (expand === 0 ? 10 : -2) + 'px' } }></i>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理键盘的选择背景色
|
||||||
|
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 (
|
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 }
|
{ iconArray }
|
||||||
{ item.__node.loading && <span class="loader"></span> }
|
{ item.__node.loading && <span class="loader"></span> }
|
||||||
{ showIcon && <i class={ iconClass } style={ iconStyle } onClick={ this.optionClick.bind(this, item, selected, item[disabled], 'checkbox') }></i> }
|
{ 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