Prevent firing the blur event if any one of its children receives focus

前端 未结 3 1346
猫巷女王i
猫巷女王i 2020-12-25 11:42

I have a div on a page that shows some info about a particular category (Image, Name etc).

When I click on the edit image it puts the category into edit mode which

3条回答
  •  春和景丽
    2020-12-25 12:28

    I faced the same issue. This what worked for me.

     handleBlur(event) {
        // if the blur was because of outside focus
        // currentTarget is the parent element, relatedTarget is the clicked element
        if (!event.currentTarget.contains(event.relatedTarget)) {
            .....
        }
    }
    

    Enjoy :)

提交回复
热议问题