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

"text", "password" or "number" input types with OnTyping mode not triggering OnValueChanged event on keystroke #9251

Open
yohanc3 opened this issue Jan 2, 2025 · 2 comments
Assignees
Labels
documentation need more info user issue An issue or bug reported by users

Comments

@yohanc3
Copy link

yohanc3 commented Jan 2, 2025

Describe the bug
When using inputs that aren't of type text, password or number, and having textUpdateMode set to onTyping, OnValueChanged event will only fire when the field loses focus (default setting).

Steps to reproduce
CodeSandbox: https://codesandbox.io/p/sandbox/stupefied-tharp-95vhdc

  1. Open the browser console
  2. Type on the email/telephone field, you'll notice the value is only logged after the field loses focus.

Expected behavior
I expected onValueChanged to fire on input fields of any type

Please complete the following information:

  • Browser: Brave
  • Browser version: 1.73.91
  • JS framework/library: React/Vanilla JS
  • SurveyJS version: v1.12.2
  • Device: MacBook Air M1

Additional context

4 years ago a related ticket was raised. While it seems fair to not allow all input types to trigger onValueChanged, I think there should be:

  1. Documentation in the API Reference regarding "onTyping" mode working only for certain input types ("text", "password" and "number" per question_text.ts line 141)

  2. An option to unlock onTyping mode for input types the developer chooses to (or for all).

This way you guys ensure the developer fully knows the risks/caveats of unlocking onTyping mode but there's a way to do it.

@yohanc3 yohanc3 changed the title "text", "password" or "number" input types with OnTyping mode not triggering OnValueChanged event "text", "password" or "number" input types with OnTyping mode not triggering OnValueChanged event on keystroke Jan 2, 2025
@yohanc3
Copy link
Author

yohanc3 commented Jan 3, 2025

One simple workaround I found was to add an email validator instead:

	{
      name: "email",
      type: "text",
      title: "Email",
      maxLength: 25,
      validators: [{ type: "email", text: "Not an email." }]
	}

This way validation happens when trying to go on to the next page, or submit the form, and onValueChanged still runs on every keystroke

@JaneSjs JaneSjs self-assigned this Jan 8, 2025
@JaneSjs JaneSjs added documentation user issue An issue or bug reported by users labels Jan 8, 2025
@JaneSjs JaneSjs assigned JaneSjs and unassigned JaneSjs Jan 8, 2025
@JaneSjs
Copy link
Contributor

JaneSjs commented Jan 9, 2025

Hello @yohanc3,
To better understand your usage scenario, could you please provide more details on the following?

  • Which specific input types do you want to handle with the onValueChanged event in the onTyping text update mode?
  • What actions are you performing when this event occurs?

Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation need more info user issue An issue or bug reported by users
Projects
None yet
Development

No branches or pull requests

2 participants