Skip to content

Commit

Permalink
feat: search input
Browse files Browse the repository at this point in the history
  • Loading branch information
杨国璇 authored and 杨国璇 committed Dec 26, 2024
1 parent 7b87b75 commit 1bf3350
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components/common/search-input.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -87,19 +88,14 @@ 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;
if (!isClearable || !searchValue) return null;
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 (
Expand Down

0 comments on commit 1bf3350

Please sign in to comment.