-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add field modal does not close on first close button click #1455
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,6 +234,8 @@ const EditModal = ({ close, data, fields, onSave, zoneType }) => { | |
/> | ||
<Close // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-assignment | ||
onClick={close} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
onMouseDown={close} // will execute the close function before Label input hijacks the focus | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this is the best way to solve this, it looks like a hack. This is a common scenario on the web (clicking a button while another element has the focus). We rarely have to duplicate the on-click handler to fix this, and with this, we're executing the close function twice (it might be ok for this particular scenario, but it is still not ideal). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure about what is exact root of the problem, it's most likely related with re-render happening when input is validated, and my idea was that after the re-render focus is brought back to input (if I disable autofocus, button works without any problem). |
||
type="button" | ||
/> | ||
</Flex> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this comment at the top of the file so we don't have to add it in each line. We said we were going to do this but if we never start we'll never do it!