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.

Add `.focus` `.blur` method for every form control components

See original GitHub issue

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:23
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
nnmrtscommented, Aug 11, 2018

@ChuckJonas That’s exactly the problem. Most of you probably want to really focus and open the rc-select component beneath the antd select component. Try this:

antdSelectRef.rcSelect.setOpenState(true, true);

You can also directly use setState on it to have full control over it. Doing it this way won’t close the select on blur:

antdSelectRef.rcSelect.setState({
    open: true
});

This is still an ugly workaround though.

EDIT: I know that you can do the same also with plain javascript and document.getElementById, but why use React when you directly manipulate the dom anyway? This is just another way of accomplishing the focus, but in a more react-compatible manner. Doing it with document.getElementById probably has complex consequences which are just not worth it.

6reactions
mths0x5fcommented, Mar 22, 2019

calling .focus() on a Select ref still does not work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Focusing: focus/blur - The Modern JavaScript Tutorial
An element receives the focus when the user either clicks on it or uses the Tab key on the keyboard. There's also an...
Read more >
Angular FormControl focus and blur Event - ConcretePage.com
On this page we will provide focus and blur events example with Angular FormControl. The focus and blur events are opposite to each...
Read more >
Focusing: focus/blur | W3docs JavaScript Tutorial
Learn the basics of focusing in this chapter. Here we cover what focus and blur are, their functions, as well as how to...
Read more >
HTMLElement.blur() - Web APIs - MDN Web Docs
The HTMLElement.blur() method removes keyboard focus from the current element. Syntax. blur()
Read more >
Add `.focus` `.blur` method for every form control components
Add `.focus` `.blur` method for every form control components · [x] auto-complete · [x] cascader · [x] checkbox · [x] date-picker · [x]...
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