Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

После merge из master (+ rm -rf node_modules и npm i) linter стал ругаться (кидать error) на require, не давая сделать commit.
Поставил ignore пока.
Вопрос: как такой вариант настройки линтера с ошибками проник в мастер? @prosto-lapsha
По идее же не только у меня должно ругаться на webpack и gulpfile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я за фижуром так пристально не смотрю) я за прайватои приглядываю, поэтому не могу дать ответ на этот вопрос

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Странно, у меня только ворнинги

const createTasks = require('library-utils/gulp-tasks');

createTasks('arui-feather', {
Expand Down
52 changes: 24 additions & 28 deletions src/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import { DeepReadonly } from 'utility-types';
import { createCn } from 'bem-react-classname';
import { withTheme } from '../cn';

import { Button } from '../button/button';
import { Button } from '../button';
import IconButton from '../icon-button/icon-button';
import IconArrowDown from '../icon/ui/arrow-down';
import IconArrowUp from '../icon/ui/arrow-up';
import Menu from '../menu/menu';
import Mq from '../mq/mq';
import ThemedPopup from '../popup/popup';
import PopupHeader from '../popup-header/popup-header';
import { ResizeSensor } from '../resize-sensor/resize-sensor';
import { ResizeSensor } from '../resize-sensor';

import { HtmlElement } from '../lib/prop-types';
import keyboardCode from '../lib/keyboard-code';
import performance from '../performance';
import scrollTo from '../lib/scroll-to';
import { SCROLL_TO_CORRECTION, SCROLL_TO_NORMAL_DURATION } from '../vars';

Expand Down Expand Up @@ -317,8 +316,7 @@ type SelectState = DeepReadonly<{
/**
* Компонент выпадающего списка.
*/
@performance(true)
export class Select extends React.Component<SelectProps, SelectState> {
export class Select extends React.PureComponent<SelectProps, SelectState> {
protected cn = createCn('select');

static defaultProps: Partial<SelectProps> = {
Expand All @@ -342,7 +340,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
};

state: SelectState = {
hasGroup: false,
// eslint-disable-next-line max-len
hasGroup: this.props.options.some((option) => !!(option.type === 'group' && !!option.content)),
isMobile: false,
opened: !!this.props.opened,
popupStyles: {},
Expand All @@ -368,13 +367,6 @@ export class Select extends React.Component<SelectProps, SelectState> {
*/
private awaitClosing = false;

// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
this.setState({
hasGroup: this.props.options.some((option) => !!(option.type === 'group' && !!option.content)),
});
}

componentDidMount() {
if (this.isAutoSelectRequired()) {
this.selectFirstOption();
Expand All @@ -384,24 +376,19 @@ export class Select extends React.Component<SelectProps, SelectState> {
this.updatePopupStyles();
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps: SelectProps) {
this.setPopupTarget();
this.updatePopupStyles();

if (this.state.opened && nextProps.disabled) {
this.toggleOpened();
}

this.setState({
hasGroup: this.props.options.some((option) => !!(option.type === 'group' && !!option.content)),
});
}

componentDidUpdate() {
if (this.state.opened) {
this.updatePopupStyles();
if (this.props.disabled) {
this.toggleOpened();
}
}
// eslint-disable-next-line max-len
const hasGroup = prevProps.options.some((option) => option.type === 'group' && !!option.content);

this.updateHasGroup(hasGroup);
}

render() {
Expand Down Expand Up @@ -1041,8 +1028,10 @@ export class Select extends React.Component<SelectProps, SelectState> {
if (this.props.equalPopupWidth) {
popupStyles.maxWidth = buttonWidth;
}

this.setState({ popupStyles });
if (this.state.popupStyles.maxWidth !== popupStyles.maxWidth
|| this.state.popupStyles.minWidth !== popupStyles.minWidth) {
this.setState({ popupStyles });
}
};

private setPopupTarget = () => {
Expand Down Expand Up @@ -1087,6 +1076,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
private isAutoSelectRequired() {
const { mode, options, renderPopupOnFocus } = this.props;

// eslint-disable-next-line max-len
return renderPopupOnFocus && mode === 'radio' && options.length > 0 && !this.hasCheckedItems();
}

Expand All @@ -1112,6 +1102,12 @@ export class Select extends React.Component<SelectProps, SelectState> {

return firstOption;
}

private updateHasGroup(hasGroup: boolean) {
if (this.state.hasGroup !== hasGroup) {
this.setState({ hasGroup });
}
}
}

class ThemedSelect extends Select {}
Expand Down
2 changes: 1 addition & 1 deletion styleguide.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint strict: [0, "global"] */
/* eslint import/no-extraneous-dependencies: 0 */

/* eslint-disable */
'use strict';

const path = require('path');
Expand Down
2 changes: 2 additions & 0 deletions webpack.base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint import/no-extraneous-dependencies: [2, {"devDependencies": true}] */

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const webpack = require('webpack');

const QUERY = {
Expand Down