Skip to content

Commit

Permalink
fix: deprecated keyCode and charCode
Browse files Browse the repository at this point in the history
  • Loading branch information
chungchiehlun committed Mar 4, 2021
1 parent 6344ee8 commit d97d721
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
SHELL := /bin/bash
NPM_BIN = ./node_modules/.bin
export PATH := $(NPM_BIN):$(PATH)

.PHONY: install test build publish

install:
yarn

clean:
./node_modules/.bin/rimraf dist es lib types

test:
yarn run test
./node_modules/.bin/jest --coverage

build: test
build: clean test
./node_modules/.bin/rollup -c

publish: build
npx standard-version
npm publish

docz-dev:
yarn run docz:dev

docz-build:
deploy_docs:
yarn run docz:build

docz-deploy: docz-build
firebase deploy

2 changes: 1 addition & 1 deletion docs/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Examples
---
import { Playground } from "docz"
import "./examples.css"
import CTE from "../dist/index.cjs.js"
import CTE from "../lib/index.js"

## Article

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"scripts": {
"docz:dev": "docz dev",
"docz:build": "docz build",
"docz:serve": "docz serve",
"build": "rollup -c",
"test": "jest --coverage"
"docz:serve": "docz serve"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test("leave editing mode when pressing the enter key", () => {
wrapper.find("span").simulate("click");
const inputWrapper = wrapper.find("input").at(0);
inputWrapper.simulate("keypress", {
keyCode: 13
code: "Enter"
});
expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith("HELLO");
Expand Down
5 changes: 1 addition & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const ClickToEdit: React.FC<Props> = (props) => {

const handleKeyPress = (e: KeyboardEvent<HTMLInputElement>) => {
if (
e.keyCode === 13 ||
e.charCode === 13 ||
e.keyCode === 27 ||
e.charCode === 27
e.code === "Escape" || e.code === "Enter"
) {
getOffEditMode();
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13917,7 +13917,7 @@ rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1:
dependencies:
glob "^7.1.3"

rimraf@^3.0.0:
rimraf@^3.0.0, rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
Expand Down

0 comments on commit d97d721

Please sign in to comment.