1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 23:29:49 +00:00

feat: search input

This commit is contained in:
杨国璇
2024-12-26 15:17:16 +08:00
parent 7b87b755a0
commit 1bf3350c8c
2 changed files with 4 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { SearchInput } from '@seafile/sf-metadata-ui-component';
import SearchInput from '../search-input';
import Option from './option';
import KeyCodes from '../../../constants/keyCodes';
import ClickOutside from './click-outside';
@@ -45,7 +45,6 @@ class SelectOptionGroup extends Component {
this.optionGroupRef.style.top = (position.y - height) + 'px';
}
this.optionGroupRef.style.opacity = 1;
this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
}
else {
if (height + top > window.innerHeight) {
@@ -181,6 +180,7 @@ class SelectOptionGroup extends Component {
<div className="option-group-search position-relative">
<SearchInput
className="option-search-control"
autoFocus={isInModal}
placeholder={searchPlaceholder}
onChange={this.onChangeSearch}
ref={this.searchInputRef}

View File

@@ -1,6 +1,7 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Utils } from '../../utils/utils';
const propTypes = {
placeholder: PropTypes.string,
@@ -87,11 +88,6 @@ class SearchInput extends Component {
}
};
isFunction = (functionToCheck) => {
const getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
};
renderClear = () => {
const { isClearable, clearClassName, components = {} } = this.props;
const { searchValue } = this.state;
@@ -99,7 +95,7 @@ class SearchInput extends Component {
const { ClearIndicator } = components;
if (React.isValidElement(ClearIndicator)) {
return React.cloneElement(ClearIndicator, { clearValue: this.clearSearch });
} else if (this.isFunction(ClearIndicator)) {
} else if (Utils.isFunction(ClearIndicator)) {
return <ClearIndicator clearValue={this.clearSearch} />;
}
return (