Skip to content

Commit

Permalink
fix(add-task-button): add flushSync to modal close (#3790)
Browse files Browse the repository at this point in the history
* fix(add-task-button): add flushSync to modal close

* fix(add-task-button): replace flushSync with callback
  • Loading branch information
jmcbgaston authored Dec 13, 2024
1 parent 15f2b65 commit 3555ff5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/elements/content-sidebar/AddTaskButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import * as React from 'react';
import { withRouter, type RouterHistory } from 'react-router-dom';

import AddTaskMenu from './AddTaskMenu';
import TaskModal from './TaskModal';
import { TASK_TYPE_APPROVAL } from '../../constants';
Expand Down Expand Up @@ -45,10 +46,11 @@ class AddTaskButton extends React.Component<Props, State> {

handleModalClose = () => {
const { onTaskModalClose } = this.props;
this.setState({ isTaskFormOpen: false, error: null });
if (this.buttonRef.current) {
this.buttonRef.current.focus();
}
this.setState({ isTaskFormOpen: false, error: null }, () => {
if (this.buttonRef.current) {
this.buttonRef.current.focus();
}
});
onTaskModalClose();
};

Expand Down

0 comments on commit 3555ff5

Please sign in to comment.