#vincent_addresselement-blur

1 messages ยท Page 1 of 1 (latest)

hollow pierBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1301679903216766977

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

mystic dagger
#

vincent_addresselement-blur

#

@ivory plover do you have a live example I can look up?
Like is the auto-complete from the browser itself or the feature inside AddressElement?

ivory plover
#

from the feature in teh address element

#

hello ๐Ÿ‘‹

mystic dagger
#

let me have a quick look and see what I can find

ivory plover
#

so far it seems like browser native autocomplete triggers a blur.

#

thank you!

mystic dagger
#

Do you have a demo I can look at since it requires a special API key from Google?

ivory plover
#

not at the moment unfortunately, its only deployed within my company org. i think there might be a demo in stripes docs

mystic dagger
#

yeah but I can't easily change that code and debug with you

mystic dagger
#

hence the ask so that you can help me help you :p

#

totally fine if you can't, in that case I'll have a look on my own and otherwise redirect you to support if I can't find anything obvious

ivory plover
#

i would have to get back to you about a demo env. To your knowlege though, there is no callback from clicking a dropdown option? i looked for one in docs but wante dto be sure

mystic dagger
#

No but I would expect both blur and change to fire

#

but all good, let me see what I can do to reproduce on my own

ivory plover
#

i just asked, boss said not to send you a link ๐Ÿ™‡โ€โ™‚๏ธ

mystic dagger
#

all good I'll figure it out

ivory plover
#

i appreciate it

mystic dagger
#

Okay I just tried it locally and it works totally fine for me and I get the BLUR event when I pick one of the options

#

Can you share some code since you can't share a demo? Like can you share how you listen for the blur event?

ivory plover
#

strange... okay. i will see if there is anything else on my end that is somehow not reacting to that.

#

sure

#
          <AddressElement
            options={{
              ...addressOptions,
              mode: "shipping",
              defaultValues: {
                name,
                address: { ...address, country: activeCountry },
              },
            }}
            onChange={onAddressUpdate}
            onBlur={onAddressBlur}
          />```
mystic dagger
#

ah it's React

ivory plover
#

ah yes

mystic dagger
#

ah you're in shipping mode, let me check if it changes something

ivory plover
#

interesting. thank you!

mystic dagger
#

nope same thing. So I think I'd need a clear repro if you can on a jsfiddle or similar.
Let me make a simple example I can show you in the meantime

ivory plover
#

thanks!

mystic dagger
#

https://jsfiddle.net/4jzedorg/ this is a really simple demo showing AddressElement + PaymentElement (just to get auto-complete to work) and if you look at the JS console the BLUR event is fired properly

ivory plover
#

ah!

#

i figured something out

#

The blur fires but before the rest of the address is in state

mystic dagger
#

ah yeah though that sounds reasonable in that case potentially, the blur happens when you click, and then we do our thing to fill out the form and you should get the change event too then right?

ivory plover
#

the form isnt filled in with the address strings

#

so the event property passed to the on blur function only has the event type, no inputs

#

i think the solution is to use change and only hit the server when the address is complete

#

and debounce

mystic dagger
#

yeah

ivory plover
#

Thank you for your help!