Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
lookup fixes #600
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed Jun 1, 2017
1 parent 49c96ee commit 0249b2a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/components/widget/List/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class List extends Component {
const {
rank, readonly, defaultValue, selected, align, updated, rowId,
emptyText, tabIndex, mandatory, validStatus, lookupList, autofocus,
blur
blur, initialFocus
} = this.props;
const {list, loading, selectedItem} = this.state;

Expand All @@ -128,6 +128,7 @@ class List extends Component {
autofocus={autofocus}
lookupList={lookupList}
blur={blur}
initialFocus={initialFocus}
/>
)
}
Expand Down
11 changes: 9 additions & 2 deletions src/components/widget/List/RawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class RawList extends Component {
}

componentDidUpdate = prevProps => {
const { list, mandatory, defaultValue, autofocus, blur } = this.props;
const {
list, mandatory, defaultValue, autofocus, blur, property,
initialFocus
} = this.props;

if(prevProps.blur != blur){
blur && this.handleBlur();
Expand All @@ -33,7 +36,11 @@ class RawList extends Component {
list.length === 1 && this.handleSelect(list[0]);
}

if(prevProps.defaultValue != defaultValue){
if(prevProps.defaultValue != defaultValue && property){
this.dropdown && this.dropdown.focus();
}

if(initialFocus && !defaultValue){
this.dropdown && this.dropdown.focus();
}

Expand Down
16 changes: 12 additions & 4 deletions src/components/widget/Lookup/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Lookup extends Component {
isInputEmpty: true,
propertiesCopy: getItemsByProperty(properties, 'source', 'list'),
property: '',
fireClickOutside: false
fireClickOutside: false,
initialFocus: false
}
}

Expand Down Expand Up @@ -93,7 +94,8 @@ class Lookup extends Component {
onChange(properties, null, false);
this.setState({
isInputEmpty: true,
property: ''
property: '',
initialFocus: true
});
}

Expand All @@ -105,7 +107,9 @@ class Lookup extends Component {
entity, dataId, tabId, subentity, subentityId, viewId, autoFocus
} = this.props;

const {isInputEmpty, property, fireClickOutside} = this.state;
const {
isInputEmpty, property, fireClickOutside, initialFocus
} = this.state;

return (
<div
Expand Down Expand Up @@ -144,6 +148,7 @@ class Lookup extends Component {
handleInputEmptyStatus={
this.handleInputEmptyStatus
}
initialFocus={index===0 ? initialFocus : false}
setNextProperty={this.setNextProperty}
{...{placeholder, readonly, tabIndex,
windowType, parameterName, entity, dataId,
Expand All @@ -170,7 +175,7 @@ class Lookup extends Component {
{...{dataId, entity, windowType,
filterWidget, tabId, rowId,
subentity, subentityId, viewId,
onChange, isInputEmpty
onChange, isInputEmpty, property
}}
properties={[item]}
lookupList={true}
Expand All @@ -184,6 +189,9 @@ class Lookup extends Component {
Object.keys(objectValue)[0]
] : ''
}
initialFocus={
index===0 ? initialFocus : false
}
setNextProperty={this.setNextProperty}
mainProperty={[item]}
blur={!property?true:false}
Expand Down
7 changes: 6 additions & 1 deletion src/components/widget/Lookup/RawLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class RawLookup extends Component {

const {
autoFocus, defaultValue, fireClickOutside, handleInputEmptyStatus,
filterWidget
filterWidget, initialFocus
} = this.props;

const {shouldBeFocused} = this.state;
if(autoFocus && !this.inputSearch.value && shouldBeFocused){
this.inputSearch.focus();
Expand All @@ -60,6 +61,10 @@ class RawLookup extends Component {
});
}

if(initialFocus && !this.inputSearch.value){
this.inputSearch.focus();
}

defaultValue && prevProps.defaultValue !== defaultValue &&
handleInputEmptyStatus(false);

Expand Down

0 comments on commit 0249b2a

Please sign in to comment.