when entering text the focus of input is lost
See original GitHub issueHi,
This is what I get.
My code is:
For the step:
const steps = [
{
selector: '#campaign_step',
content: ({ goTo }) => (
<div>
<p>{i18n.leaders['Welcome to Leaders Market, start by entering the name of the campaign you\'ll be working on']}</p>
<p>{i18n.leaders['For example: New sunglasses campaign']}</p>
<button
className="btn btn-adv-teal"
onClick={() => goTo(1)} >
{i18n.leaders['Next step']}
</button>
</div>
),
// stepInteraction:true,
position:'right',
action: node => {
// by using this, focus trap is temporary disabled
node.children[1].focus()
console.log(node)
},
},
]
The Tour:
<div className="rtl">
<Tour
// closeWithMask={true}
disableKeyboardNavigation={true}
// disableInteraction={false}
onAfterOpen={this.disableBody}
onBeforeClose={this.enableBody}
steps={steps}
rounded={5}
showNavigation={false}
showButtons={false}
isOpen={this.state.tourOpen}
onRequestClose={this.closeTour}
/>
</div>
For the input:
<div id="campaign_step">
<h4
className={this.state.errors.campaign_name && 'help-block-error-bold'}
>
{i18n.leaders['Campaign name']}
</h4>
<input
id="campaign_name"
type="text"
tabIndex="1"
onChange={value => {
if (value) {
document.getElementById('camp_name').textContent =
value.target.value
}
this.setState({
activityEdit: {
...this.state.activityEdit,
name: value.target.value,
},
})
}}
onBlur={value => {
let campaignError = value.target.value == '' ? true : false
if (campaignError !== this.state.errors.campaign_name) {
this.setState({
errors: {
...this.state.errors,
campaign_name: campaignError,
},
})
}
}}
className="form-control form-control-adv adv-input-field"
name="campaign_name"
// placeholder={i18n.leaders['Campaign name']}
value={this.state.activityEdit.name}
/>
</div>
Thanks a lot!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
In React ES6, why does the input field lose focus after typing a ...
When your onChange event fires, the callback calls setState with the new title value, which gets passed to your text field as a...
Read more >React Text Input Losing Focus After Each Keypress
Click back into the text input. Then type the final 'o'. Obviously that is messed up. The problem was, I was defining a...
Read more >Focusing: focus/blur - The Modern JavaScript Tutorial
Losing the focus generally means: “the data has been entered”, so we can run the code to check it or even to save...
Read more >React.js loses input focus on typing
I recently stumbled upon an interesting problem. React.js was loosing focus on an input while the user was typing. Here is a video...
Read more >.focusout() | jQuery API Documentation
Type : Anything ... Watch for a loss of focus to occur inside paragraphs and note the ... "#focus-count" ).text( "focusout fired: "...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @Alpa84, You are re-rendering the Component where the Tour is in, so with each
state
change, you are re-rendering an open Tour, and this is the reason why you are loosingfocus
on theinput
.Try separating components like in this fork
I use disableFocusLock as true can fix this problem. #209