examples icon indicating copy to clipboard operation
examples copied to clipboard

chore: implement Internet Identity example recommendations

Open krpeacock opened this issue 1 year ago • 0 comments

Here are some recommendations I have on best practices in the II example project.

Important and functional changes

  • AuthClient create should not be invoked during the login flow
    • Awaiting async behavior during the click event leads browsers to treat the interaction as a popup and reject it. This is a particular footgun for Safari mobile
    • fix: move AuthClient.create() into the global scope, and then update the Actor globally
  • Disable login button and greet button until the authClient is ready
  • Remove Promise wrapping of login
    • I get that await is fancy, but the actual browser API is based around callbacks and events, and onSuccess and onError are adequate.
    • Note: I would also accept the wrapping if it at least rejected in the onError callback

Less important (semantic HTML, a11y, and style)

  • Using window.greetActor and window.authClient instead of local variables so new devs can play with the objects in the console. We DO NOT have to accept this change - it's just an idea I had
  • The form elements are unnecessary without input elements, and don't add any semantic value. I prefer <button type="button"> over an empty form, and then we don't need to handle submit events

krpeacock avatar Oct 24 '24 19:10 krpeacock