Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 react 16 版本 event 对象缺失 code 属性判断错误 #1526

Merged
merged 2 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/date-picker/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
allowInput | Boolean | false | 是否允许输入日期 | N
clearable | Boolean | false | 是否显示清楚按钮 | N
disableDate | Object / Array / Function | - | 禁用日期,示例:['A', 'B'] 表示日期 A 和日期 B 会被禁用。{ from: 'A', to: 'B' } 表示在 A 到 B 之间的日期会被禁用。{ before: 'A', after: 'B' } 表示在 A 之前和在 B 之后的日期都会被禁用。其中 A = '2021-01-01',B = '2021-02-01'。值类型为 Function 则表示返回值为 true 的日期会被禁用。TS 类型:`DisableRangeDate` `type DisableRangeDate = Array<DateValue> | DisableDateObj | ((context: { date: DateRangeValue; partial: DateRangePickerPartial }) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }` `type DateRangePickerPartial = 'start' | 'end'`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/date-picker/type.ts) | N
disabled | Boolean | - | 是否禁用组件,值为数组表示可分别控制开始日期和结束日期是否禁用 | N
disabled | Boolean | - | 是否禁用组件 | N
enableTimePicker | Boolean | false | 是否显示时间选择 | N
firstDayOfWeek | Number | - | 第一天从星期几开始。可选项:1/2/3/4/5/6/7 | N
format | String | - | 用于格式化日期,[详细文档](https://day.js.org/docs/en/display/format) | N
Expand Down
2 changes: 1 addition & 1 deletion src/date-picker/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface TdDateRangePickerProps {
*/
disableDate?: DisableRangeDate;
/**
* 是否禁用组件,值为数组表示可分别控制开始日期和结束日期是否禁用
* 是否禁用组件
*/
disabled?: boolean;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/dialog/RenderDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ const RenderDialog = forwardRef((props: RenderDialogProps, ref: React.Ref<HTMLDi

const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
if (e.code === 'Escape') {
if (e.key === 'Escape') {
e.stopPropagation();
onEscKeydown({ e });
if (closeOnEscKeydown ?? local.closeOnEscKeydown) {
onClose({ e, trigger: 'esc' });
}
} else if (e.code === 'Enter' || e.code === 'NumpadEnter') {
} else if (e.key === 'Enter' || e.key === 'NumpadEnter') {
// 回车键触发点击确认事件
e.stopPropagation();
if (confirmOnEnter) {
Expand Down
2 changes: 1 addition & 1 deletion src/image-viewer/ImageViewerModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export const ImageModal = (props: ImageModalProps) => {

const onKeyDown = useCallback(
(event) => {
switch (event.code) {
switch (event.key) {
case 'ArrowRight':
return next();
case 'ArrowLeft':
Expand Down
6 changes: 3 additions & 3 deletions src/input-number/useInputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ export default function useInputNumber<T extends InputNumberValue = InputNumberV
ArrowUp: handleAdd,
ArrowDown: handleReduce,
};
const code = e.code || e.key;
if (keyEvent[code] !== undefined) {
keyEvent[code](e);

if (keyEvent[e.key] !== undefined) {
keyEvent[e.key](e);
}
props.onKeydown?.(value, ctx);
};
Expand Down
2 changes: 1 addition & 1 deletion src/range-input/range-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
activeIndex | Number | - | 输入框高亮状态序号 | N
clearable | Boolean | false | 是否可清空 | N
disabled | Boolean | - | 是否禁用范围输入框,值为数组表示可分别控制某一个输入框是否禁用 | N
disabled | Boolean | - | 是否禁用范围输入框 | N
format | Array / Function | - | 指定输入框展示值的格式。TS 类型:`InputFormatType | Array<InputFormatType>` | N
inputProps | Object / Array | - | 透传 Input 输入框组件全部属性,数组第一项表示第一个输入框属性,第二项表示第二个输入框属性。示例:`[{ label: 'A', name: 'A-name' }, { label: 'B', name: 'B-name' }]`。TS 类型:`InputProps | Array<InputProps>`[Input API Documents](./input?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/range-input/type.ts) | N
label | TNode | - | 左侧内容。TS 类型:`string | TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
Expand Down
2 changes: 1 addition & 1 deletion src/range-input/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface TdRangeInputProps {
*/
clearable?: boolean;
/**
* 是否禁用范围输入框,值为数组表示可分别控制某一个输入框是否禁用
* 是否禁用范围输入框
*/
disabled?: boolean;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/tag-input/useTagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function useTagList(props: TagInputProps) {
const { e } = context;
if (!tagValue || !tagValue.length) return;
// 回车键删除,输入框值为空时,才允许 Backspace 删除标签
if (!oldInputValue && ['Backspace', 'NumpadDelete'].includes(e.code)) {
if (!oldInputValue && ['Backspace', 'NumpadDelete'].includes(e.key)) {
const index = tagValue.length - 1;
const item = tagValue[index];
const trigger = 'backspace';
Expand Down