Material-ui: [Select] triggered onBlur event.target element is the selected option

Created on 5 Mar 2018  路  2Comments  路  Source: mui-org/material-ui

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Setting onBlur event on a select TextField I expect the triggered onBlur event.target to be the TextField.

Current Behavior

It is the selected option (or MenuItem) element.

Context

I'm abstracting away form validation and submission. I use both onChange and onBlur event.target to get the value and name attributes of that element. Since onBlur event.target name is now undefined I get it from the props.

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | beta35 |
| React | 16.2.0 |
| browser | Chrome 64 |

Select question

Most helpful comment

I expect the triggered onBlur event.target to be the TextField.

@galki Please mind the difference between event.target and event.currentTarget:

  • target is whatever you actually clicked on. It can vary, as this can be within an element that the event was bound to.
  • currentTarget is the element you actually bound the event to. This will never change.

All 2 comments

@galki Do you have a live reproduction example?

I expect the triggered onBlur event.target to be the TextField.

@galki Please mind the difference between event.target and event.currentTarget:

  • target is whatever you actually clicked on. It can vary, as this can be within an element that the event was bound to.
  • currentTarget is the element you actually bound the event to. This will never change.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

zabojad picture zabojad  路  3Comments

newoga picture newoga  路  3Comments

sys13 picture sys13  路  3Comments

rbozan picture rbozan  路  3Comments

chris-hinds picture chris-hinds  路  3Comments