import { Component, linkEvent } from 'inferno';
-import { SortType } from '../interfaces';
-import { sortingHelpUrl } from '../utils';
+import { SortType } from 'lemmy-js-client';
+import { sortingHelpUrl, randomStr } from '../utils';
import { i18n } from '../i18next';
interface SortSelectProps {
}
export class SortSelect extends Component<SortSelectProps, SortSelectState> {
+ private id = `sort-select-${randomStr()}`;
private emptyState: SortSelectState = {
sort: this.props.sort,
};
this.state = this.emptyState;
}
- static getDerivedStateFromProps(props) {
- console.log('sort-select', props);
+ static getDerivedStateFromProps(props: any): SortSelectState {
return {
- sort: Number(props.sort),
+ sort: props.sort,
};
}
return (
<>
<select
+ id={this.id}
+ name={this.id}
value={this.state.sort}
onChange={linkEvent(this, this.handleSortChange)}
- class="custom-select custom-select-sm w-auto mr-2"
+ class="custom-select w-auto mr-2 mb-2"
>
<option disabled>{i18n.t('sort_type')}</option>
{!this.props.hideHot && (
- <option value={SortType.Hot}>{i18n.t('hot')}</option>
+ <>
+ <option value={SortType.Active}>{i18n.t('active')}</option>
+ <option value={SortType.Hot}>{i18n.t('hot')}</option>
+ </>
)}
<option value={SortType.New}>{i18n.t('new')}</option>
<option disabled>─────</option>