navcoin / WhisperWallet

Whisper Wallet
5 stars 4 forks source link

Send Tokens screen does not auto select From field when sending to someone #123

Closed aguycalled closed 2 years ago

aguycalled commented 2 years ago

On the “send tokens” screen (after having said “send to someone” using TEST), the token I’m sending from isn’t selected by default

tsejerome commented 2 years ago

Cudn't replicate, can send some steps? thanks!

tsejerome commented 2 years ago

image Tried with both the mnemonic @aguycalled mentioned , cudnt be able to replicate on iOS and Android

aguycalled commented 2 years ago

https://user-images.githubusercontent.com/24814046/167189199-3ccac129-abf8-4b62-b0a5-f5e1d7c35d9c.mp4

aguycalled commented 2 years ago

The bug is in CardSelect. defaultOption is received in the component but not stored in the state.

const CardSelect = ({
  text,
  defaultOption,
  options,
  onSelect,
}: InputSelectProps) => {
  const theme = useTheme();
  const [selectedOption, setSelectedOption] = useState(defaultOption);
  const styles = useStyleSheet(themedStyles);
  const bottomSheet = useBottomSheet();

  console.log('selectedOption', selectedOption, 'defaultOption', defaultOption)
....

outputs:

 LOG  selectedOption  defaultOption TestToken account (100 TEST)
aguycalled commented 2 years ago

adding

  useEffect(() => {
    setSelectedOption(defaultOption)
  }, [defaultOption]);

solves it

aguycalled commented 2 years ago

fixed in https://github.com/navcoin/WhisperWallet/commit/0d9fdf8a0a8aea45e639aaf9b510be17920afd54