U
U
Username2018-08-22 13:52:22
React
Username, 2018-08-22 13:52:22

How to prevent an input field from jumping when focus is lost?

Wrote to the TextField component, if the field is in focus, then it has one style, if not, then another.
If you type some text and click the cross, the field will clear and a flickering change of style will occur as the field lost focus and regained it.
How can I get rid of this flicker?
https://codesandbox.io/s/6vmkjy141r

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-08-22
@dalv_happy

Making a method:

onMouseDown(e) {
  e.preventDefault();
}

And add it to the delete value button as a handler for the corresponding event:
onMouseDown={this.onMouseDown}

I
Igor, 2018-08-22
@iluminat777

Add to imput border: 1px solid transparent; When you focus, 2 pixels of height are added due to the border, from here the height changes and there is a jump, if you need to change the color of the border when focusing, then simply changes the border-color. not the size of the border.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question