Skip to content
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

Allow paste + enter to select pasted address #1786

Closed
jacogr opened this issue Oct 28, 2019 · 11 comments · Fixed by #1964
Closed

Allow paste + enter to select pasted address #1786

jacogr opened this issue Oct 28, 2019 · 11 comments · Fixed by #1964

Comments

@jacogr
Copy link
Member

jacogr commented Oct 28, 2019

Currently you need to select via mouse

@JunichiSugiura
Copy link
Contributor

Can you describe the steps to produce this scenario?

@jacogr
Copy link
Member Author

jacogr commented Nov 20, 2019

So what happens -

  • the user pastes an address into eg. Recipient for transfer
  • the input box adds the address, but you need to physically select it from the drop down (it gets added as a “recent”)

Ideally what should happen is that the address is pasted and just automatically either selected or when pressing enter, it is selected.

@JunichiSugiura
Copy link
Contributor

Ah! Now I know what you mean. Thank you.
Let me try fixing this tomorrow.

@JunichiSugiura
Copy link
Contributor

It seems that when a user pastes an address and hit enter, state updates with the pasted address. Then somehow another state change happens with the old address. Thus it looks like hitting enter doesn't update state. The same thing happens when a user hits arrow keys.

@JunichiSugiura
Copy link
Contributor

Commenting out this line fixes the issues but I'm not confident to remove the useEffect hook.

https://github.com/polkadot-js/apps/blob/master/packages/react-components/src/Dropdown.tsx#L65

@jacogr
Copy link
Member Author

jacogr commented Nov 21, 2019

Will take a peek as well, and see what the negatives could be.

Thanks you very much for the investigation and investment of time.

@jacogr
Copy link
Member Author

jacogr commented Nov 23, 2019

Not sure about the above change at all - so on any changes (real changes), it should alert the parent. It is exceptionally weird that that "makes it work", sadly I think we are going to chase breakages elsewhere then where forms rely on this behavior :(

The good news is that it probably brings us one step closer understanding, and that is good.

@JunichiSugiura
Copy link
Contributor

I don't fully understand why the Dropdown component needs to hold any state in the first place. Usually, all form states should be managed by a form level component not filed level component.

@jacogr
Copy link
Member Author

jacogr commented Nov 23, 2019

So the InputAddress does a couple of things that you certainly don't want to delegate to all upper-layer forms -

  • it keeps tracks of the last used per type, so for instance if you selected a "from account", the next time the component renders that is the default
  • it handles stuff like recently users lists for addresses, i.e. when a new address is entered, it gets added to "recents"

So with stuff likes "enter a balance", yes, the upper-layer should 100% take care of it.

@JunichiSugiura
Copy link
Contributor

I feel like #1930 will give us a same result that you described above. Let me know if I missed some details.

@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants