question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Radiogroup & Checkboxes not auto-focused when going to next page

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

Bug

What is the current behavior?

Currently in the new version 1.0.56, after going to the next page, the first question is not auto-focused if it’s a radiogroup or checkbox group (instead it focuses the Next button).

What is the expected behavior?

First choice should be auto-focused.

How would you reproduce the current behavior (if this is a bug)?

In the sample React survey in the examples/react folder, copy-paste the below JSON

Provide the test code and the tested page URL (if applicable)

Test JSON

{
	"pages": [{
			"name": "page1",
			"elements": [{
				"type": "text",
				"name": "CC_01",
				"title": "How old are you?",
				"isRequired": true,
				"validators": [{
					"type": "numeric",
					"minValue": 18,
					"maxValue": 99
				}],
				"placeHolder": "(years)"
			}]
		},
		{
			"name": "page2",
			"elements": [{
				"type": "radiogroup",
				"name": "CC_02",
				"title": "What is your sex?",
				"isRequired": true,
				"choices": [{
						"value": "M",
						"text": "Male"
					},
					{
						"value": "F",
						"text": "Female"
					}
				]
			}]
		},
		{
			"name": "page3",
			"elements": [{
				"type": "checkbox",
				"name": "CC_03",
				"title": "Favourite colours?",
				"isRequired": true,
				"choices": [{
						"value": "B",
						"text": "Blue"
					},
					{
						"value": "R",
						"text": "Red"
					}
				]
			}]
		}
	]
}

Specify your

  • browser: Chrome
  • browser version: 70.0.3538.77
  • surveyjs platform (angular or react or jquery or knockout or vue): react
  • surveyjs version: 1.0.56

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tsv2013commented, Nov 23, 2018

@ekim-novus Thank you for investigations. You are absolutely right. I’ve moved setSurveyEvents into updateSurvey method. If functional tests will be ok, I’ll leave this solution.

0reactions
ekim-novuscommented, Nov 22, 2018

@tsv2013 I just discovered that the reason onCurrentPageChangedHandler was not being called, is because a second ReactSurveyModel is being created, which replaces the first one.

Working In the example React survey, when the survey initially loads:

  1. the constructor of reactSurvey.tsx calls:
  • updateSurvey() which creates a new ReactSurveyModel
  • setSurveyEvents(), which adds the onCurrentPageChangedHandler
  1. componentWillReceiveProps() is not called

Not Working However, in my local project, when the survey loads:

  1. the constructor in reactSurvey.tsx is called (same as above)
  2. componentWillReceiveProps() is called right after the constructor, where:
  • updateSurvey() creates a new ReactSurveyModel
  • but setSurveyEvents() is not called, so onCurrentPageChangedHandler is not added

As a suggestion, should setSurveyEvents() be called right after updateSurvey() inside componentWillReceiveProps? Unless that may cause other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue, autofocus on radio button - Stack Overflow
I am trying to autofocus on the first radio button so that the user can automatically began cycling through answers with the tab...
Read more >
<input type="radio"> - HTML: HyperText Markup Language
A radio group is defined by giving each of radio buttons in the group the same name . Once a radio group is...
Read more >
Tabbing through form never gives focus to radio buttons or c
Hello, I'm having an issue where when I have either radio buttons or checkboxes on a form in Angular they never gain focus...
Read more >
Radio | NextUI - Beautiful, fast and modern React UI Library
Radio.Group : Radio group component that holds all radios in a group and provides a common API for managing the group state. Radio:...
Read more >
HTML DOM Input Radio autofocus property - Tutorialspoint
Setting the autofocus property. ... Here, true represents the radio button should get focus and false represents otherwise. It is set to false...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found