refactor: autoFocus to autofocus
parent
00069605c0
commit
566bbb4873
|
@ -1 +1 @@
|
||||||
Subproject commit fe4a4e29aebe7cc1a5bbacf43c2b34671b00c880
|
Subproject commit 43f89955b59abfd51bdfd4d9dcbc3b4fc4c481b0
|
|
@ -45,7 +45,7 @@ const AutoComplete = {
|
||||||
showSearch: PropTypes.bool.def(false),
|
showSearch: PropTypes.bool.def(false),
|
||||||
transitionName: PropTypes.string.def('slide-up'),
|
transitionName: PropTypes.string.def('slide-up'),
|
||||||
choiceTransitionName: PropTypes.string.def('zoom'),
|
choiceTransitionName: PropTypes.string.def('zoom'),
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
backfill: PropTypes.bool,
|
backfill: PropTypes.bool,
|
||||||
optionLabelProp: PropTypes.string.def('children'),
|
optionLabelProp: PropTypes.string.def('children'),
|
||||||
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]).def(false),
|
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]).def(false),
|
||||||
|
|
|
@ -90,7 +90,7 @@ const CascaderProps = {
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
popupVisible: PropTypes.bool,
|
popupVisible: PropTypes.bool,
|
||||||
fieldNames: FieldNamesType,
|
fieldNames: FieldNamesType,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
suffixIcon: PropTypes.any,
|
suffixIcon: PropTypes.any,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ const Cascader = {
|
||||||
},
|
},
|
||||||
// mounted() {
|
// mounted() {
|
||||||
// this.$nextTick(() => {
|
// this.$nextTick(() => {
|
||||||
// if (this.autoFocus && !this.showSearch && !this.disabled) {
|
// if (this.autofocus && !this.showSearch && !this.disabled) {
|
||||||
// this.$refs.picker.focus();
|
// this.$refs.picker.focus();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
indeterminate: PropTypes.bool,
|
indeterminate: PropTypes.bool,
|
||||||
type: PropTypes.string.def('checkbox'),
|
type: PropTypes.string.def('checkbox'),
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const PickerProps = () => ({
|
||||||
pickerClass: PropTypes.string,
|
pickerClass: PropTypes.string,
|
||||||
pickerInputClass: PropTypes.string,
|
pickerInputClass: PropTypes.string,
|
||||||
timePicker: PropTypes.any,
|
timePicker: PropTypes.any,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
tagPrefixCls: PropTypes.string,
|
tagPrefixCls: PropTypes.string,
|
||||||
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
align: PropTypes.object.def(() => ({})),
|
align: PropTypes.object.def(() => ({})),
|
||||||
|
|
|
@ -59,10 +59,10 @@ export default function wrapPicker(Picker, props, pickerType) {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const { autoFocus, disabled, value, defaultValue, valueFormat } = this;
|
const { autofocus, disabled, value, defaultValue, valueFormat } = this;
|
||||||
checkValidate('DatePicker', defaultValue, 'defaultValue', valueFormat);
|
checkValidate('DatePicker', defaultValue, 'defaultValue', valueFormat);
|
||||||
checkValidate('DatePicker', value, 'value', valueFormat);
|
checkValidate('DatePicker', value, 'value', valueFormat);
|
||||||
if (autoFocus && !disabled) {
|
if (autofocus && !disabled) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.focus();
|
this.focus();
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,7 +24,7 @@ export const InputNumberProps = {
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
precision: PropTypes.number,
|
precision: PropTypes.number,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputNumber = {
|
const InputNumber = {
|
||||||
|
|
|
@ -157,8 +157,8 @@ export default {
|
||||||
onInput: handleChange,
|
onInput: handleChange,
|
||||||
onChange: noop,
|
onChange: noop,
|
||||||
};
|
};
|
||||||
if (!inputProps.autoFocus) {
|
if (!inputProps.autofocus) {
|
||||||
delete inputProps.autoFocus;
|
delete inputProps.autofocus;
|
||||||
}
|
}
|
||||||
return <input {...inputProps} />;
|
return <input {...inputProps} />;
|
||||||
},
|
},
|
||||||
|
|
|
@ -142,8 +142,8 @@ const ResizableTextArea = {
|
||||||
// },
|
// },
|
||||||
// ],
|
// ],
|
||||||
};
|
};
|
||||||
if (!textareaProps.autoFocus) {
|
if (!textareaProps.autofocus) {
|
||||||
delete textareaProps.autoFocus;
|
delete textareaProps.autofocus;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize)}>
|
<ResizeObserver onResize={this.handleResize} disabled={!(autoSize || autosize)}>
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default {
|
||||||
prefix: PropTypes.any,
|
prefix: PropTypes.any,
|
||||||
suffix: PropTypes.any,
|
suffix: PropTypes.any,
|
||||||
// spellCheck: Boolean,
|
// spellCheck: Boolean,
|
||||||
autoFocus: Boolean,
|
autofocus: Boolean,
|
||||||
allowClear: Boolean,
|
allowClear: Boolean,
|
||||||
lazy: {
|
lazy: {
|
||||||
default: true,
|
default: true,
|
||||||
|
|
|
@ -66,7 +66,7 @@ const Mentions = {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.autoFocus) {
|
if (this.autofocus) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ const ActionButtonProps = {
|
||||||
type: ButtonType,
|
type: ButtonType,
|
||||||
actionFn: PropTypes.func,
|
actionFn: PropTypes.func,
|
||||||
closeModal: PropTypes.func,
|
closeModal: PropTypes.func,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
buttonProps: PropTypes.object,
|
buttonProps: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.autoFocus) {
|
if (this.autofocus) {
|
||||||
this.timeoutId = setTimeout(() => this.$el.focus());
|
this.timeoutId = setTimeout(() => this.$el.focus());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,7 +48,7 @@ const ConfirmDialog = (_, { attrs }) => {
|
||||||
<ActionButton
|
<ActionButton
|
||||||
actionFn={onCancel}
|
actionFn={onCancel}
|
||||||
closeModal={close}
|
closeModal={close}
|
||||||
autoFocus={autoFocusButton === 'cancel'}
|
autofocus={autoFocusButton === 'cancel'}
|
||||||
buttonProps={cancelButtonProps}
|
buttonProps={cancelButtonProps}
|
||||||
>
|
>
|
||||||
{cancelText}
|
{cancelText}
|
||||||
|
@ -94,7 +94,7 @@ const ConfirmDialog = (_, { attrs }) => {
|
||||||
type={okType}
|
type={okType}
|
||||||
actionFn={onOk}
|
actionFn={onOk}
|
||||||
closeModal={close}
|
closeModal={close}
|
||||||
autoFocus={autoFocusButton === 'ok'}
|
autofocus={autoFocusButton === 'ok'}
|
||||||
buttonProps={okButtonProps}
|
buttonProps={okButtonProps}
|
||||||
>
|
>
|
||||||
{okText}
|
{okText}
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default {
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
name: String,
|
name: String,
|
||||||
id: String,
|
id: String,
|
||||||
autoFocus: Boolean,
|
autofocus: Boolean,
|
||||||
type: PropTypes.string.def('radio'),
|
type: PropTypes.string.def('radio'),
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const RateProps = {
|
||||||
tooltips: PropTypes.arrayOf(PropTypes.string),
|
tooltips: PropTypes.arrayOf(PropTypes.string),
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
character: PropTypes.any,
|
character: PropTypes.any,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Rate = {
|
const Rate = {
|
||||||
|
|
|
@ -37,7 +37,7 @@ const AbstractSelectProps = () => ({
|
||||||
dropdownMatchSelectWidth: PropTypes.bool,
|
dropdownMatchSelectWidth: PropTypes.bool,
|
||||||
// onSearch: (value: string) => any,
|
// onSearch: (value: string) => any,
|
||||||
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
filterOption: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
backfill: PropTypes.bool,
|
backfill: PropTypes.bool,
|
||||||
showArrow: PropTypes.bool,
|
showArrow: PropTypes.bool,
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
|
|
|
@ -21,7 +21,7 @@ const Switch = {
|
||||||
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
checked: PropTypes.bool,
|
checked: PropTypes.bool,
|
||||||
defaultChecked: PropTypes.bool,
|
defaultChecked: PropTypes.bool,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
loading: PropTypes.bool,
|
loading: PropTypes.bool,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -64,7 +64,7 @@ export const TimePickerProps = () => ({
|
||||||
align: PropTypes.object,
|
align: PropTypes.object,
|
||||||
placement: PropTypes.any,
|
placement: PropTypes.any,
|
||||||
transitionName: PropTypes.string,
|
transitionName: PropTypes.string,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
addon: PropTypes.any,
|
addon: PropTypes.any,
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
locale: PropTypes.object,
|
locale: PropTypes.object,
|
||||||
|
|
|
@ -11,7 +11,7 @@ export const TreeData = PropTypes.shape({
|
||||||
|
|
||||||
export const TreeSelectProps = () => ({
|
export const TreeSelectProps = () => ({
|
||||||
...AbstractSelectProps(),
|
...AbstractSelectProps(),
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
dropdownStyle: PropTypes.object,
|
dropdownStyle: PropTypes.object,
|
||||||
filterTreeNode: PropTypes.oneOfType([Function, Boolean]),
|
filterTreeNode: PropTypes.oneOfType([Function, Boolean]),
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
||||||
// onClick: PropTypes.func,
|
// onClick: PropTypes.func,
|
||||||
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
readonly: PropTypes.bool,
|
readonly: PropTypes.bool,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (this.autoFocus) {
|
if (this.autofocus) {
|
||||||
this.$refs.input && this.$refs.input.focus();
|
this.$refs.input && this.$refs.input.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -102,7 +102,7 @@ export default {
|
||||||
disabled,
|
disabled,
|
||||||
readonly,
|
readonly,
|
||||||
tabindex,
|
tabindex,
|
||||||
autoFocus,
|
autofocus,
|
||||||
onFocus,
|
onFocus,
|
||||||
onBlur,
|
onBlur,
|
||||||
value,
|
value,
|
||||||
|
@ -130,7 +130,7 @@ export default {
|
||||||
tabindex,
|
tabindex,
|
||||||
class: `${prefixCls}-input`,
|
class: `${prefixCls}-input`,
|
||||||
checked: !!sChecked,
|
checked: !!sChecked,
|
||||||
autoFocus,
|
autofocus,
|
||||||
value,
|
value,
|
||||||
...globalProps,
|
...globalProps,
|
||||||
onChange: this.handleChange,
|
onChange: this.handleChange,
|
||||||
|
|
|
@ -45,7 +45,7 @@ const inputNumberProps = {
|
||||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||||
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||||
focusOnUpDown: PropTypes.bool,
|
focusOnUpDown: PropTypes.bool,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
// onChange: PropTypes.func,
|
// onChange: PropTypes.func,
|
||||||
// onKeyDown: PropTypes.func,
|
// onKeyDown: PropTypes.func,
|
||||||
// onKeyUp: PropTypes.func,
|
// onKeyUp: PropTypes.func,
|
||||||
|
@ -110,12 +110,12 @@ export default {
|
||||||
return {
|
return {
|
||||||
inputValue: this.toPrecisionAsStep(validValue),
|
inputValue: this.toPrecisionAsStep(validValue),
|
||||||
sValue: validValue,
|
sValue: validValue,
|
||||||
focused: this.autoFocus,
|
focused: this.autofocus,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.autoFocus && !this.disabled) {
|
if (this.autofocus && !this.disabled) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
this.updatedFunc();
|
this.updatedFunc();
|
||||||
|
@ -540,8 +540,8 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
toNumber(num) {
|
toNumber(num) {
|
||||||
const { precision, autoFocus } = this.$props;
|
const { precision, autofocus } = this.$props;
|
||||||
const { focused = autoFocus } = this;
|
const { focused = autofocus } = this;
|
||||||
// num.length > 16 => This is to prevent input of large numbers
|
// num.length > 16 => This is to prevent input of large numbers
|
||||||
const numberIsTooLarge = num && num.length > 16 && focused;
|
const numberIsTooLarge = num && num.length > 16 && focused;
|
||||||
if (this.isNotCompleteNumber(num) || numberIsTooLarge) {
|
if (this.isNotCompleteNumber(num) || numberIsTooLarge) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ const Mentions = {
|
||||||
prefixCls,
|
prefixCls,
|
||||||
placement,
|
placement,
|
||||||
transitionName,
|
transitionName,
|
||||||
autoFocus,
|
autofocus,
|
||||||
notFoundContent,
|
notFoundContent,
|
||||||
getPopupContainer,
|
getPopupContainer,
|
||||||
...restProps
|
...restProps
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
import { PlaceMent } from './placement';
|
import { PlaceMent } from './placement';
|
||||||
|
|
||||||
export const mentionsProps = {
|
export const mentionsProps = {
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
prefix: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
prefix: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
value: PropTypes.string,
|
value: PropTypes.string,
|
||||||
|
|
|
@ -17,7 +17,7 @@ const rateProps = {
|
||||||
character: PropTypes.any,
|
character: PropTypes.any,
|
||||||
characterRender: PropTypes.func,
|
characterRender: PropTypes.func,
|
||||||
tabindex: PropTypes.number,
|
tabindex: PropTypes.number,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
function noop() {}
|
function noop() {}
|
||||||
|
@ -56,7 +56,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.autoFocus && !this.disabled) {
|
if (this.autofocus && !this.disabled) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ export const SelectPropTypes = {
|
||||||
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
|
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
|
||||||
getInputElement: PropTypes.func,
|
getInputElement: PropTypes.func,
|
||||||
showAction: PropTypes.arrayOf(PropTypes.string),
|
showAction: PropTypes.arrayOf(PropTypes.string),
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
inputIcon: PropTypes.any,
|
inputIcon: PropTypes.any,
|
||||||
|
|
|
@ -158,7 +158,7 @@ const Select = {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
// when defaultOpen is true, we should auto focus search input
|
// when defaultOpen is true, we should auto focus search input
|
||||||
// https://github.com/ant-design/ant-design/issues/14254
|
// https://github.com/ant-design/ant-design/issues/14254
|
||||||
if (this.autoFocus || this._open) {
|
if (this.autofocus || this._open) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
// this.setState({
|
// this.setState({
|
||||||
|
|
|
@ -34,7 +34,7 @@ const rangeProps = {
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
min: PropTypes.number,
|
min: PropTypes.number,
|
||||||
max: PropTypes.number,
|
max: PropTypes.number,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
const Range = {
|
const Range = {
|
||||||
name: 'Range',
|
name: 'Range',
|
||||||
|
|
|
@ -13,7 +13,7 @@ const Slider = {
|
||||||
defaultValue: PropTypes.number,
|
defaultValue: PropTypes.number,
|
||||||
value: PropTypes.number,
|
value: PropTypes.number,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
tabindex: PropTypes.number,
|
tabindex: PropTypes.number,
|
||||||
reverse: PropTypes.bool,
|
reverse: PropTypes.bool,
|
||||||
min: PropTypes.number,
|
min: PropTypes.number,
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default function createSlider(Component) {
|
||||||
railStyle: PropTypes.object,
|
railStyle: PropTypes.object,
|
||||||
dotStyle: PropTypes.object,
|
dotStyle: PropTypes.object,
|
||||||
activeDotStyle: PropTypes.object,
|
activeDotStyle: PropTypes.object,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
name: 'createSlider',
|
name: 'createSlider',
|
||||||
|
@ -75,8 +75,8 @@ export default function createSlider(Component) {
|
||||||
// Snapshot testing cannot handle refs, so be sure to null-check this.
|
// Snapshot testing cannot handle refs, so be sure to null-check this.
|
||||||
this.document = this.$refs.sliderRef && this.$refs.sliderRef.ownerDocument;
|
this.document = this.$refs.sliderRef && this.$refs.sliderRef.ownerDocument;
|
||||||
// this.setHandleRefs()
|
// this.setHandleRefs()
|
||||||
const { autoFocus, disabled } = this;
|
const { autofocus, disabled } = this;
|
||||||
if (autoFocus && !disabled) {
|
if (autofocus && !disabled) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,6 @@ export const switchPropTypes = {
|
||||||
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
tabindex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
checked: PropTypes.bool,
|
checked: PropTypes.bool,
|
||||||
defaultChecked: PropTypes.bool.def(false),
|
defaultChecked: PropTypes.bool.def(false),
|
||||||
autoFocus: PropTypes.bool.def(false),
|
autofocus: PropTypes.bool.def(false),
|
||||||
loadingIcon: PropTypes.any,
|
loadingIcon: PropTypes.any,
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,8 +32,8 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const { autoFocus, disabled } = this;
|
const { autofocus, disabled } = this;
|
||||||
if (autoFocus && !disabled) {
|
if (autofocus && !disabled) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -84,7 +84,7 @@ export default {
|
||||||
disabled,
|
disabled,
|
||||||
loadingIcon,
|
loadingIcon,
|
||||||
defaultChecked,
|
defaultChecked,
|
||||||
autoFocus,
|
autofocus,
|
||||||
...restProps
|
...restProps
|
||||||
} = getOptionProps(this);
|
} = getOptionProps(this);
|
||||||
const checked = this.stateChecked;
|
const checked = this.stateChecked;
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default {
|
||||||
secondStep: PropTypes.number,
|
secondStep: PropTypes.number,
|
||||||
focusOnOpen: PropTypes.bool,
|
focusOnOpen: PropTypes.bool,
|
||||||
// onKeyDown: PropTypes.func,
|
// onKeyDown: PropTypes.func,
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
inputIcon: PropTypes.any,
|
inputIcon: PropTypes.any,
|
||||||
clearIcon: PropTypes.any,
|
clearIcon: PropTypes.any,
|
||||||
|
@ -116,7 +116,7 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.autoFocus) {
|
if (this.autofocus) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -335,7 +335,7 @@ export default {
|
||||||
getPopupContainer,
|
getPopupContainer,
|
||||||
name,
|
name,
|
||||||
autocomplete,
|
autocomplete,
|
||||||
autoFocus,
|
autofocus,
|
||||||
inputReadOnly,
|
inputReadOnly,
|
||||||
sOpen,
|
sOpen,
|
||||||
sValue,
|
sValue,
|
||||||
|
@ -374,7 +374,7 @@ export default {
|
||||||
autocomplete={autocomplete}
|
autocomplete={autocomplete}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
autoFocus={autoFocus}
|
autofocus={autofocus}
|
||||||
readonly={!!inputReadOnly}
|
readonly={!!inputReadOnly}
|
||||||
id={id}
|
id={id}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -81,7 +81,7 @@ const Select = {
|
||||||
open: PropTypes.bool,
|
open: PropTypes.bool,
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
|
|
||||||
autoFocus: PropTypes.bool,
|
autofocus: PropTypes.bool,
|
||||||
|
|
||||||
defaultOpen: PropTypes.bool,
|
defaultOpen: PropTypes.bool,
|
||||||
defaultValue: PropTypes.any,
|
defaultValue: PropTypes.any,
|
||||||
|
@ -258,8 +258,8 @@ const Select = {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const { autoFocus, disabled } = this.$props;
|
const { autofocus, disabled } = this.$props;
|
||||||
if (autoFocus && !disabled) {
|
if (autofocus && !disabled) {
|
||||||
this.focus();
|
this.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,13 +44,13 @@ export default function focusTest(Component) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('autoFocus', done => {
|
it('autofocus', done => {
|
||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
const handleFocus = jest.fn();
|
const handleFocus = jest.fn();
|
||||||
mount(
|
mount(
|
||||||
{
|
{
|
||||||
render(h) {
|
render(h) {
|
||||||
return <Component autoFocus onFocus={handleFocus} />;
|
return <Component autofocus onFocus={handleFocus} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ attachToDocument: true, sync: false },
|
{ attachToDocument: true, sync: false },
|
||||||
|
|
|
@ -22,7 +22,7 @@ export declare class AutoComplete extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backfill selected item the input when using keyboard
|
* backfill selected item the input when using keyboard
|
||||||
|
|
|
@ -59,7 +59,7 @@ export declare class Cascader extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* change value on each selection if set to true.
|
* change value on each selection if set to true.
|
||||||
|
|
|
@ -13,7 +13,7 @@ export declare class Checkbox extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the checkbox is selected.
|
* Specifies whether the checkbox is selected.
|
||||||
|
|
|
@ -18,7 +18,7 @@ export declare class DatepickerCommon extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custom rendering function for date cells by setting a scoped slot
|
* custom rendering function for date cells by setting a scoped slot
|
||||||
|
|
|
@ -10,7 +10,7 @@ export declare class InputNumber extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initial value
|
* initial value
|
||||||
|
|
|
@ -11,7 +11,7 @@ export declare class Mentions extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default value
|
* Default value
|
||||||
|
|
|
@ -15,7 +15,7 @@ export declare class Radio extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the radio is selected.
|
* Specifies whether the radio is selected.
|
||||||
|
|
|
@ -24,7 +24,7 @@ export declare class Rate extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custom character of rate
|
* custom character of rate
|
||||||
|
|
|
@ -30,7 +30,7 @@ export declare class Select extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether active first option by default
|
* Whether active first option by default
|
||||||
|
|
|
@ -11,7 +11,7 @@ export declare class Slider extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default value of slider. When range is false, use number, otherwise, use [number, number]
|
* The default value of slider. When range is false, use number, otherwise, use [number, number]
|
||||||
|
|
|
@ -10,7 +10,7 @@ export declare class Switch extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* determine whether the Switch is checked
|
* determine whether the Switch is checked
|
||||||
|
|
|
@ -24,7 +24,7 @@ export declare class TimePicker extends AntdComponent {
|
||||||
* @default false
|
* @default false
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
autoFocus: boolean;
|
autofocus: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear tooltip of icon
|
* clear tooltip of icon
|
||||||
|
|
Loading…
Reference in New Issue