Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
fix: handle invalid address from qr code (#1645)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated committed Feb 26, 2020
1 parent 743d7a0 commit cf96f4b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/renderer/components/Input/InputAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,14 @@ export default {
return this.neoCheckedAddressess[address]
},
onBlur (evt) {
onBlur (event) {
// Verifies that the element that generated the blur was a dropdown item
if (evt.relatedTarget) {
const classList = evt.relatedTarget.classList || []
const isDropdownItem = includes(classList, 'MenuDropdownItem__button')
if (event.relatedTarget) {
const classList = event.relatedTarget.classList
const isDropdownItem = classList && typeof classList.contains === 'function'
? classList.contains('MenuDropdownItem__button')
: false
if (!isDropdownItem) {
this.closeDropdown()
Expand Down
18 changes: 11 additions & 7 deletions src/renderer/components/Input/InputDelegate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import ModalQrCodeScanner from '@/components/Modal/ModalQrCodeScanner'
import { MenuDropdown } from '@/components/Menu'
import Cycled from 'cycled'
import InputField from './InputField'
import truncate from '@/filters/truncate'
import { isEmpty, orderBy } from 'lodash'
export default {
Expand Down Expand Up @@ -176,7 +175,7 @@ export default {
publicKey: object.publicKey
}
delegate.name = `${truncate(object.username, 25)} (${this.wallet_truncate(object.address)})`
delegate.name = `${object.username} (${this.wallet_truncate(object.address)})`
return delegate
})
Expand Down Expand Up @@ -239,11 +238,14 @@ export default {
this.$refs.input.focus()
},
onBlur (evt) {
onBlur (event) {
// Verifies that the element that generated the blur was a dropdown item
if (evt.relatedTarget) {
const classList = evt.relatedTarget.classList || []
const isDropdownItem = classList.includes('MenuDropdownItem__button')
if (event.relatedTarget) {
const classList = event.relatedTarget.classList
const isDropdownItem = classList && typeof classList.contains === 'function'
? classList.contains('MenuDropdownItem__button')
: false
if (!isDropdownItem) {
this.closeDropdown()
Expand Down Expand Up @@ -306,7 +308,9 @@ export default {
this.$error(this.$t('MODAL_QR_SCANNER.DECODE_FAILED', { data: value }))
}
this.model = this.$store.getters['delegate/byAddress'](address).username
const delegate = this.$store.getters['delegate/byAddress'](address)
this.model = delegate ? delegate.username : address
this.$nextTick(() => {
this.closeDropdown()
toggle()
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/components/Input/InputSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ export default {
onBlur (event) {
// To ensure that the code is evaluated after other tasks
setTimeout(() => {
if (Object.values(document.activeElement.classList).includes('MenuDropdownItem__button')) {
const classList = document.activeElement.classList
const isDropdownItem = classList && typeof classList.contains === 'function'
? classList.contains('MenuDropdownItem__button')
: false
if (isDropdownItem) {
event.preventDefault()
} else {
this.$refs.dropdown.close()
Expand Down

0 comments on commit cf96f4b

Please sign in to comment.