Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/shared/ButtonWithPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export class ButtonWithPanel extends React.PureComponent<Props, State> {
};

_onPanelClose = () => {
this.setState({ open: false });

// Let's focus the delete button after dismissing the dialog, but _only_ if
// the focus was part of the dialog before.
// Note this branch isn't tested because jsdom doesn't support the
Expand All @@ -116,6 +114,8 @@ export class ButtonWithPanel extends React.PureComponent<Props, State> {

closePanel() {
if (this._panel && this.state.open) {
// Close immediately so the button doesn't stay active while the panel animates out.
this.setState({ open: false });
Comment thread
fatadel marked this conversation as resolved.
this._panel.close();
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/components/ButtonWithPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,20 @@ describe('shared/ButtonWithPanel', () => {
});
expect(container.querySelector('.arrowPanel.open')).toBe(null);
});

it('marks the button as no longer open as soon as the panel starts closing', () => {
const { container } = setup();

fireFullClick(screen.getByText('My Button'));
act(() => {
jest.runAllTimers();
});
ensureExists(container.querySelector('.buttonWithPanel.open'));

fireFullClick(screen.getByText('My Button'));

// Timers are deliberately not run: the panel is still animating out.
expect(container.querySelector('.buttonWithPanel.open')).toBe(null);
ensureExists(container.querySelector('.arrowPanel'));
});
});
Loading