]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/common/comment-sort-select.tsx
component classes v2
[lemmy-ui.git] / src / shared / components / common / comment-sort-select.tsx
index b87f26664c4a8859855f7bfccd7be5a954303ac4..e9885afa052aff42086e1f548dbb35398494eef9 100644 (file)
@@ -18,13 +18,12 @@ export class CommentSortSelect extends Component<
   CommentSortSelectState
 > {
   private id = `sort-select-${randomStr()}`;
-  private emptyState: CommentSortSelectState = {
+  state: CommentSortSelectState = {
     sort: this.props.sort,
   };
 
   constructor(props: any, context: any) {
     super(props, context);
-    this.state = this.emptyState;
   }
 
   static getDerivedStateFromProps(props: any): CommentSortSelectState {
@@ -41,19 +40,19 @@ export class CommentSortSelect extends Component<
           name={this.id}
           value={this.state.sort}
           onChange={linkEvent(this, this.handleSortChange)}
-          class="custom-select w-auto mr-2 mb-2"
+          className="sort-select form-select d-inline-block w-auto me-2 mb-2"
           aria-label={i18n.t("sort_type")}
         >
           <option disabled aria-hidden="true">
             {i18n.t("sort_type")}
           </option>
-          <option value={CommentSortType.Hot}>{i18n.t("hot")}</option>,
-          <option value={CommentSortType.Top}>{i18n.t("top")}</option>,
-          <option value={CommentSortType.New}>{i18n.t("new")}</option>
-          <option value={CommentSortType.Old}>{i18n.t("old")}</option>
+          <option value={"Hot"}>{i18n.t("hot")}</option>,
+          <option value={"Top"}>{i18n.t("top")}</option>,
+          <option value={"New"}>{i18n.t("new")}</option>
+          <option value={"Old"}>{i18n.t("old")}</option>
         </select>
         <a
-          className="text-muted"
+          className="sort-select-help text-muted"
           href={sortingHelpUrl}
           rel={relTags}
           title={i18n.t("sorting_help")}
@@ -65,6 +64,6 @@ export class CommentSortSelect extends Component<
   }
 
   handleSortChange(i: CommentSortSelect, event: any) {
-    i.props.onChange(event.target.value);
+    i.props.onChange?.(event.target.value);
   }
 }