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

Input Text: Fehler, wenn man den type auf "email" ändert. #2445

Open
christoph-schlumpf opened this issue May 31, 2023 · 5 comments
Open

Input Text: Fehler, wenn man den type auf "email" ändert. #2445

christoph-schlumpf opened this issue May 31, 2023 · 5 comments
Labels

Comments

@christoph-schlumpf
Copy link

christoph-schlumpf commented May 31, 2023

Der Input Text wirf einen Fehler, wenn man den type auf "email" ändert. Tritt bei der Verwendung als React Component auf.

Expected Behavior

Keine Fehlermeldung in der Console, wenn an InputText mit type 'email' verwendet.

Current Behavior

Error in der Browser Console: Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('email') does not support selection.

Steps to Reproduce

  1. Put the Input Text inside a React Application (React18.x)
  2. Set the type to „email“
  3. Start the app
  4. Try to enter an email into the input text
  5. Error as discribed above is shown in the Console (e.g. Edge-Browser)

We alredy have shown the issue to a Webhub Developer and he confirmed the issue. Feel free to contaxt me so I can show you the issue in our app.

Context (Environment)

React Application. Wir benutzen axa-input-text: '6.3.0', axa-popup: '5.0.9'

Possible Solution

@thomas-krueger-axa
Copy link
Contributor

Hi @christoph-schlumpf , could you please add the "Steps to Reproduce"?

@christoph-schlumpf
Copy link
Author

Hi @thomas-krueger-axa,

I have added „Steps to reproduce“. I suspect this issue always happens in a React app. If you have an example where this issue does not happen inside React we would be glad to have a look at it.

Best regards,
Christoph

@markus-walther
Copy link
Contributor

@christoph-schlumpf This is a consequence of using React with input components in controlled mode. Since that's one of the bad ideas of React, it's exceedingly hard if not impossible to override browser-native stateful HTML elements in all aspects. The error message says that for whatever reason a type-email input cannot set the selectionrange, i.e. where the cursor is. We added setting the selectionrange for another 'bug', also controlled mode. Of course we could fix this new issue by not setting selectionrange when input of type email is used, but the better approach - which we would ask to try - is to just use uncontrolled components, while still achieving your desired UX. Please report back here after you tried that systematic workaround.

@christoph-schlumpf
Copy link
Author

Hi @markus-walther ,

We will have a look at your proposal to use the component in Uncontrolled mode. We will inform you about our results.

Best regards

PS: Please keep this issue open untill we can confirm that the proposed solution is OK in our UX.

@christoph-schlumpf
Copy link
Author

Hi @markus-walther,
I can confirm that as an uncontrolled component the error does not happen. We were able to use an uncontrolled input-text in our UX. Thank you!

As many React applications use controlled components I would suggest that you nevertheless fix the issue. Additionally it would be very helpful to mention in the documentation on https://axa-ch-webhub-cloud.github.io/plib-feature/develop/?path=/story/components-input-text--input-text -> "Usage" that the component should only be used as an uncontrolled component in React because there are issues when it is used as a controlled component.

Best regards,
Christoph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants