Skip to content

Commit

Permalink
fix(ui-a11y-utils): fix modal closing when losing focus
Browse files Browse the repository at this point in the history
Closes: INSTUI-3790
  • Loading branch information
balzss committed Jul 14, 2023
1 parent 4f54935 commit 5deda70
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/ui-a11y-utils/src/FocusRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class FocusRegion {
addEventListener(doc, 'mousedown', this.captureDocumentClick, true)
)
this._listeners.push(
addEventListener(doc, 'mousedown', this.handleDocumentClick)
addEventListener(doc, 'click', this.handleDocumentClick)
)

Array.from(doc.getElementsByTagName('iframe')).forEach((el) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ describe('<ColorPicker />', () => {

const colorButtons = await cp.findColorPresetButtons()

await colorButtons[1].mouseDown()
await colorButtons[1].click()

const addButton = await popoverContent.findPopoverButtonWithText('add')
Expand Down Expand Up @@ -705,6 +706,7 @@ describe('<ColorPicker />', () => {

const colorButtons = await cp.findColorPresetButtons()

await colorButtons[1].mouseDown()
await colorButtons[1].click()

const addButton = await popoverContent.findPopoverButtonWithText('add')
Expand Down Expand Up @@ -1012,6 +1014,7 @@ describe('<ColorPicker />', () => {

const colorButtons = await cp.findColorPresetButtons()

await colorButtons[1].mouseDown()
await colorButtons[1].click()

const addButton = await popoverContent.findPopoverButtonWithText('add')
Expand Down Expand Up @@ -1070,6 +1073,7 @@ describe('<ColorPicker />', () => {

const colorButtons = await cp.findColorPresetButtons()

await colorButtons[1].mouseDown()
await colorButtons[1].click()

const addButton = await popoverContent.findPopoverButtonWithText('add')
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-dialog/src/Dialog/__tests__/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('<Dialog />', async () => {
expect(dialog.containsFocus()).to.be.true()
})

await within(dialog.getOwnerDocument().documentElement).mouseDown()
await within(dialog.getOwnerDocument().documentElement).click()

await wait(() => {
expect(onDismiss).to.have.been.called()
Expand Down
4 changes: 1 addition & 3 deletions packages/ui-menu/src/Menu/__tests__/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,7 @@ describe('<Menu />', async () => {
})

onToggle.resetHistory()
await wrapQueryResult(
trigger.getOwnerDocument().documentElement
).mouseDown()
await wrapQueryResult(trigger.getOwnerDocument().documentElement).click()

expect(onToggle).to.have.been.called()
expect(onToggle.getCall(0).args[0]).to.equal(false)
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-modal/src/Modal/__tests__/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('<Modal />', async () => {
expect(modal.containsFocus()).to.be.true()
})

await (within(modal.getOwnerDocument().documentElement) as any).mouseDown()
await (within(modal.getOwnerDocument().documentElement) as any).click()

await wait(() => {
expect(onDismiss).to.have.been.called()
Expand Down Expand Up @@ -494,7 +494,7 @@ describe('<Modal />', async () => {
await btn.click()

// to trigger the modal to close
await (within(modal.getOwnerDocument().documentElement) as any).mouseDown()
await (within(modal.getOwnerDocument().documentElement) as any).click()

expect(handleDissmiss).to.have.been.calledWith(1)
})
Expand Down
4 changes: 1 addition & 3 deletions packages/ui-popover/src/Popover/__tests__/Popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ describe('<Popover />', async () => {
await wait(() => {
expect(content.containsFocus()).to.be.true()
})
await wrapQueryResult(
trigger.getOwnerDocument().documentElement
).mouseDown()
await wrapQueryResult(trigger.getOwnerDocument().documentElement).click()

content = await popover.findContent({ expectEmpty: true })

Expand Down

0 comments on commit 5deda70

Please sign in to comment.