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

Autofocus option #275

Open
mateusbw opened this issue Mar 11, 2024 · 0 comments
Open

Autofocus option #275

mateusbw opened this issue Mar 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mateusbw
Copy link

mateusbw commented Mar 11, 2024

I'm currently working on some ADA requirements adjustments and i need the Google Pay button to be on focus when my page loads.

I tried a couple different solutions. The one i currently have is to use the onReadyToPayChange callback and if isButtonVisible is true, i get the button via jquery and force the focus.

onReadyToPayChange={({ isButtonVisible }) => {
  if (!isButtonVisible) return;
  const [button] = $('.gpay-button');

  if (button) {
    button.focus();
  }
}}

I would like to be able to the pass the html autoFocus attribute as a prop instead of forcing the focus using js.

I could't find in the Google Pay API docs the option to pass the attribute. So one possible solution could be to add the autofocus attribute (and any other native html attr) after the Google Pay client creates the button.

const button = this.client.createButton(buttonOptions);
button.firstChild.autofocus = this.config.autofocus;
@mateusbw mateusbw added the enhancement New feature or request label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant