Skip to content

Commit

Permalink
Close both toolbars when editor loses focus
Browse files Browse the repository at this point in the history
  • Loading branch information
JereNurminen committed Nov 25, 2024
1 parent 2993dff commit ea1bdb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion playwright/editor.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,22 @@ test.describe('Rich text editor', () => {
await expect(page.getByTestId('math-toolbar')).toBeVisible()
})

await test.step('hides math commands when math editor closes', async () => {
await test.step('hides math commands when math editor closes via Esc press', async () => {
await inputLatexCommandFromToolbar(page, specialCharacters.sqrt[0])
await page.keyboard.press('Escape')
await expect(page.getByTestId('math-toolbar')).not.toBeVisible()
})
})

test('closes both bars when user clicks outside editor text area when equation editor is open', async ({
page,
}) => {
await page.keyboard.press('Control+e')
await page.keyboard.type('123')
await clickOutsideEditor(page)
await expect(page.getByTestId('toolbar')).not.toBeVisible()
await expect(page.getByTestId('math-toolbar')).not.toBeVisible()
})
})

test.describe('Editor history', () => {
Expand Down
1 change: 1 addition & 0 deletions src/app/state/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export function EditorStateProvider({

setActiveMathEditor(null)
setIsMathToolbarOpen(false)
setIsToolbarOpen(false)

onAnswerChange(true, true)

Expand Down

0 comments on commit ea1bdb8

Please sign in to comment.