Skip to content

Commit

Permalink
fix regression: handle dismiss on escape
Browse files Browse the repository at this point in the history
  • Loading branch information
goblindegook committed Jun 27, 2019
1 parent 5f4788e commit 9a63f9e
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 98 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

## [Unreleased]

## [2.0.1] - 2019-06-27

### Changed

- Fixed regression with pressing the Escape key to dismiss footnotes.

## [2.0.0] - 2019-06-10

littlefoot has been rewritten in [TypeScript](https://www.typescriptlang.org), which enabled a cleaner architecture and slight reduction in bundle size. Browser compatibility is not as extensive as with 1.0.x, and I will no longer support older versions of Internet Explorer.
Expand Down Expand Up @@ -87,4 +93,5 @@ Breakpoint methods were dropped in favour of a CSS-based approach. Override the
The markup for the footnote button ellipsis changed from three `<svg>` elements with a `<circle>` each to a single `<svg>` element containing all three `<circle>`s.

[Unreleased]: https://github.com/goblindegook/littlefoot/compare/v2.0.0...HEAD
[2.0.1]: https://github.com/goblindegook/littlefoot/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/goblindegook/littlefoot/compare/v1.0.9...v2.0.0
3 changes: 2 additions & 1 deletion src/adapter/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function handleHover(
}

function handleEscape(fn: () => void): EventHandler<KeyboardEvent> {
return event => event.key === '27' && fn()
// tslint:disable-next-line:deprecation
return event => event.keyCode === 27 && fn()
}

function scrollHandler(event: WheelEvent): void {
Expand Down
6 changes: 2 additions & 4 deletions test/dismiss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ test('dismiss all footnotes when calling .dismiss()', async () => {
})

test('dismiss footnote when pressing the Escape key', async () => {
const KEY_ESCAPE = '27'
littlefoot(TEST_SETTINGS)

const button = getButton('1')
fireEvent.click(button)
await waitForChange(button)

fireEvent.keyUp(document.body, { key: KEY_ESCAPE })

expect(button).toHaveClass('is-changing')
fireEvent.keyUp(document.body, { keyCode: 27 })
await waitForChange(button)

expect(button).not.toHaveClass('is-active')
})

Expand Down
4 changes: 0 additions & 4 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@
],
"deprecation": true,
"member-access": true,
// "no-default-export": true,
"no-duplicate-super": true,
"no-duplicate-switch-case": true,
"no-duplicate-variable": true,
"no-inferrable-types": true,
// "no-non-null-assertion": true,
"no-object-literal-type-assertion": true,
"no-parameter-reassignment": true,
"no-reference": true,
"no-shadowed-variable": true,
"no-unnecessary-class": true,
"no-use-before-declare": true,
// "no-var-requires": true,
"prefer-const": true,
"prefer-function-over-method": true,
"promise-function-async": true,
Expand Down
Loading

0 comments on commit 9a63f9e

Please sign in to comment.