-
Notifications
You must be signed in to change notification settings - Fork 18
[DDW-603] Enable pasting of wallet recovery phrase #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DeeJayElly
wants to merge
25
commits into
develop
Choose a base branch
from
feature/ddw-603-enable-pasting-of-wallet-recovery-phrase
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6ebce44
DDW-603 - Enable pasting of wallet recovery phrase - updates for sing…
DeeJayElly 8611a8d
DDW-603 - Enable pasting of wallet recovery phrase - updates for sing…
DeeJayElly 121b7c5
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly 65e2b2d
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly 83a7876
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly 1259fb4
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly fed8427
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly 3419fdc
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly 2bfbcc3
Merge branch 'feature/ddw-603-enable-pasting-of-wallet-recovery-phras…
DeeJayElly f866f8d
DDW-603 - Enable pasting of wallet recovery phrase - updates for mult…
DeeJayElly ce4a326
DDW-603 - Enable pasting of wallet recovery phrase - updates for mult…
DeeJayElly 5094cb1
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly fe0f88e
DDW-603 - Enable pasting of wallet recovery phrase - updates for mult…
DeeJayElly 67c1a38
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DeeJayElly d335973
DDW-603 - Enable pasting of wallet recovery phrase - fixing event js …
DeeJayElly 54079a9
Merge remote-tracking branch 'origin/feature/ddw-603-enable-pasting-o…
DeeJayElly 2f93290
DDW-603 - Enable pasting of wallet recovery phrase - fixing focus
DeeJayElly 1fb856a
DDW-603 - Enable pasting of wallet recovery phrase - fixing click rem…
DeeJayElly 5bd423e
DDW-603 - Enable pasting of wallet recovery phrase - fixing click rem…
DeeJayElly f3478bd
DDW-603 - Enable pasting of wallet recovery phrase - updating version…
DeeJayElly 4d96e1f
DDW-603 - Enable pasting of wallet recovery phrase - fixes for dropdown
DeeJayElly 26e5704
DDW-603 - Enable pasting of wallet recovery phrase - fixes for event …
DeeJayElly ba15d3c
[603] WIP: remove autocomplete click handler
DominikGuzei d7ec120
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DominikGuzei 30535ca
Merge branch 'develop' into feature/ddw-603-enable-pasting-of-wallet-…
DominikGuzei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ type State = { | |
inputValue: string, | ||
mouseIsOverOptions: boolean, | ||
selectedOptions: Array<any>, | ||
isRemoveWordClicked: boolean, | ||
}; | ||
|
||
class AutocompleteBase extends Component<AutocompleteProps, State> { | ||
|
@@ -101,6 +102,7 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
filteredOptions: | ||
sortAlphabetically && options ? options.sort() : options || [], | ||
isOpen: false, | ||
isRemoveWordClicked: false, | ||
mouseIsOverOptions: false, | ||
composedTheme: composeTheme( | ||
addThemeId(theme || context.theme, themeId), | ||
|
@@ -149,20 +151,23 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
}; | ||
|
||
onKeyDown = (event: SyntheticKeyboardEvent<>) => { | ||
if ( | ||
// Check for backspace in order to delete the last selected option | ||
event.keyCode === 8 && | ||
!event.target.value && | ||
this.state.selectedOptions.length | ||
) { | ||
// Remove last selected option | ||
this.removeOption(this.state.selectedOptions.length - 1, event); | ||
} else if (event.keyCode === 27) { | ||
// ESCAPE key: Stops propagation & modal closing | ||
event.stopPropagation(); | ||
} else if (event.keyCode === 13) { | ||
// ENTER key: Opens suggestions | ||
this.open(); | ||
if (event) { | ||
if ( | ||
// Check for backspace in order to delete the last selected option | ||
event.keyCode === 8 && | ||
!event.target.value && | ||
this.state.selectedOptions.length | ||
) { | ||
// Remove last selected option | ||
this.close(); | ||
this.removeOption(this.state.selectedOptions.length - 1); | ||
} else if (event.keyCode === 27) { | ||
// ESCAPE key: Stops propagation & modal closing | ||
event.stopPropagation(); | ||
} else if (event.keyCode === 13) { | ||
// ENTER key: Opens suggestions | ||
this.open(); | ||
} | ||
} | ||
}; | ||
|
||
|
@@ -174,24 +179,24 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
this._setInputValue(value); | ||
if (hasMultipleValues) { | ||
this.open(); | ||
setTimeout(() => { | ||
this.updateSelectedOptions(event, multipleValues); | ||
}, 0); | ||
} | ||
setTimeout(() => { | ||
this.updateSelectedOptions(multipleValues, multipleValues.length === 1); | ||
}, 0); | ||
}; | ||
|
||
// passed to Options onChange handler in AutocompleteSkin | ||
handleChange = (option: any, event: SyntheticEvent<>) => { | ||
this.updateSelectedOptions(event, option); | ||
handleChange = (option: any) => { | ||
this.updateSelectedOptions(option); | ||
}; | ||
|
||
updateSelectedOptions = ( | ||
event: SyntheticEvent<>, | ||
selectedOption: any = null | ||
selectedOption: any = null, | ||
singleInput?: boolean, | ||
) => { | ||
const { maxSelections, multipleSameSelections, options } = this.props; | ||
const { selectedOptions, isOpen } = this.state; | ||
let { filteredOptions } = this.state; | ||
const { filteredOptions } = this.state; | ||
const canMoreOptionsBeSelected = | ||
maxSelections != null ? selectedOptions.length < maxSelections : true; | ||
const areFilteredOptionsAvailable = | ||
|
@@ -206,14 +211,14 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
selectedOption.trim() : selectedOption.filter(item => item); | ||
const newSelectedOptions: Array<string> = [...selectedOptions]; | ||
if (option && Array.isArray(option)) { | ||
filteredOptions = options; | ||
option.forEach(item => { | ||
const optionCanBeSelected = multipleSameSelections && | ||
filteredOptions.includes(item) || | ||
(filteredOptions.includes(item) && | ||
const optionCanBeSelected = (multipleSameSelections && | ||
options.includes(item) && !singleInput && option.length > 1) || | ||
(options.includes(item) && | ||
!selectedOptions.includes(item) && | ||
!newSelectedOptions.includes(item)); | ||
if (!optionCanBeSelected && !skipValueSelection) { | ||
!newSelectedOptions.includes(item) && option.length > 1); | ||
if ((!optionCanBeSelected && !skipValueSelection) || | ||
(singleInput && !selectedOptions.length)) { | ||
this._setInputValue(item, true); | ||
skipValueSelection = true; | ||
return; | ||
|
@@ -230,28 +235,31 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
!selectedOptions.includes(option); | ||
if (option && optionCanBeSelected && isOpen) { | ||
newSelectedOptions.push(option); | ||
skipValueSelection = false; | ||
} | ||
} | ||
this.selectionChanged(newSelectedOptions, event); | ||
this.selectionChanged(newSelectedOptions); | ||
this.setState({ selectedOptions: newSelectedOptions, isOpen: false }); | ||
} else { | ||
skipValueSelection = true; | ||
} | ||
if (!skipValueSelection) { | ||
this._setInputValue(''); | ||
} | ||
}; | ||
|
||
removeOption = (index: number, event: SyntheticEvent<>) => { | ||
removeOption = (index: number) => { | ||
const { selectedOptions } = this.state; | ||
_.pullAt(selectedOptions, index); | ||
this.selectionChanged(selectedOptions, event); | ||
this.setState({ selectedOptions }); | ||
this.close(); | ||
this.selectionChanged(selectedOptions); | ||
this.setState({ selectedOptions, isRemoveWordClicked: true }); | ||
}; | ||
|
||
selectionChanged = ( | ||
selectedOptions: Array<any>, | ||
event: SyntheticEvent<any> | ||
selectedOptions: Array<any> | ||
) => { | ||
if (this.props.onChange) this.props.onChange(selectedOptions, event); | ||
if (this.props.onChange) this.props.onChange(selectedOptions); | ||
}; | ||
|
||
// returns an object containing props, theme, and method handlers | ||
|
@@ -267,10 +275,10 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
isOpen, | ||
selectedOptions, | ||
theme: composedTheme[themeId], | ||
removeSelection: (index: number, event: SyntheticEvent<>) => | ||
removeSelection: (index: number) => | ||
// the user's custom removeSelection event handler is composed with | ||
// the internal functionality of Autocomplete (this.removeOption) | ||
composeFunctions(removeSelection, this.removeOption)(index, event), | ||
composeFunctions(removeSelection, this.removeOption)(index), | ||
}; | ||
}; | ||
|
||
|
@@ -305,7 +313,16 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
error={error || this.state.error} | ||
filteredOptions={this.state.filteredOptions} | ||
getSelectionProps={this.getSelectionProps} | ||
handleAutocompleteClick={this.handleAutocompleteClick} | ||
handleAutocompleteClick={() => { | ||
setTimeout(() => { | ||
const { isRemoveWordClicked } = this.state; | ||
if (!isRemoveWordClicked) { | ||
this.handleAutocompleteClick(); | ||
} else { | ||
this.setState((prevState) => ({ isRemoveWordClicked: !prevState.isRemoveWordClicked })); | ||
} | ||
}, 0); | ||
}} | ||
|
||
handleChange={this.handleChange} | ||
handleInputChange={this.handleInputChange} | ||
inputRef={this.inputElement} | ||
|
@@ -374,15 +391,15 @@ class AutocompleteBase extends Component<AutocompleteProps, State> { | |
selectedOptions = [...selectedOptions, ...this._filterOptions(filteredValue)]; | ||
}); | ||
this.setState({ | ||
isOpen: true, | ||
isOpen: !!multipleValues.length, | ||
inputValue: '', | ||
filteredOptions: Array.from(new Set(selectedOptions)), | ||
}); | ||
} else { | ||
const filteredValue = this._filterInvalidChars(value); | ||
const filteredOptions = this._filterOptions(filteredValue); | ||
this.setState({ | ||
isOpen: !!value, | ||
isOpen: value === '' ? false : !!value, | ||
inputValue: filteredValue, | ||
filteredOptions, | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.