Skip to content

Commit

Permalink
improvement(ToolWindows): prevent focus loss when stipe buttons are b…
Browse files Browse the repository at this point in the history
…eing pressed
  • Loading branch information
alirezamirian committed Oct 2, 2023
1 parent eda3709 commit 792953a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/jui/src/ToolWindows/ToolWindowStripe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function ToolWindowStripeButton<T, S>({
const { pressProps } = {
pressProps: {
onPointerUp: onPress,
onMouseDown: (e) => {
e.preventDefault();
},
} as HTMLAttributes<HTMLElement>,
}; //usePress({ onPress });
const props = useElementMove({
Expand Down
17 changes: 17 additions & 0 deletions packages/jui/src/ToolWindows/ToolWindows.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ describe("ToolWindows", () => {

cy.findByTestId("main content focusable").should("have.focus");
});

it("keeps focus where it is, when stripe buttons are being pressed", () => {
cy.mount(
<ThemeProvider theme={new Theme(darculaThemeJson as any)}>
<SimpleToolWindows />
</ThemeProvider>
);
cy.findByTestId("First window stripe button").click();
cy.findByTestId("First window focusable 1").should("be.focused");
cy.findByTestId("First window stripe button").realMouseDown();
cy.findByTestId("First window focusable 1").should("be.focused");
cy.findByTestId("First window stripe button").realMouseMove(10, 50);
cy.findByTestId("First window focusable 1").should("be.focused");
cy.get("body").realMouseUp();
cy.findByTestId("First window focusable 1").should("be.focused");
});

/**
* Known issue. FIXME. See DefaultToolWindow for more info
*/
Expand Down

0 comments on commit 792953a

Please sign in to comment.