mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Merge pull request #1198 from bbassie/feature/mod-search-focus
Focus the mod search inputs when they open
This commit is contained in:
2 files changed
+7
-3
No files matched your search
@@ -182,6 +182,7 @@ function SearchModsTable(props: SearchModsTableProps) {
|
|||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Input
|
<Input
|
||||||
|
autoFocus
|
||||||
placeholder="Search Mods"
|
placeholder="Search Mods"
|
||||||
style={{ marginBottom: 8 }}
|
style={{ marginBottom: 8 }}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React, { Fragment, useState, useContext, useEffect, useMemo } from "react";
|
import React, { Fragment, useState, useContext, useEffect, useMemo, useRef } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
Button, Form, Input, Modal, Popconfirm, Space, Table, Typography, Upload, Alert, Select, Tooltip, notification,
|
Button, Form, Input, InputRef, Modal, Popconfirm, Space, Table, Typography, Upload, Alert, Select, Tooltip,
|
||||||
|
notification,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import {
|
import {
|
||||||
ImportOutlined, PlusOutlined, SearchOutlined, DownloadOutlined,
|
ImportOutlined, PlusOutlined, SearchOutlined, DownloadOutlined,
|
||||||
@@ -147,6 +148,7 @@ function SearchModsButton() {
|
|||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const nameInputRef = useRef<InputRef>(null);
|
||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
const [factorioVersion, setFactorioVersion] = useState<lib.MajorMinorVersion>("2.0");
|
const [factorioVersion, setFactorioVersion] = useState<lib.MajorMinorVersion>("2.0");
|
||||||
|
|
||||||
@@ -333,6 +335,7 @@ function SearchModsButton() {
|
|||||||
title="Search Mod Portal"
|
title="Search Mod Portal"
|
||||||
open={open}
|
open={open}
|
||||||
onCancel={() => { setOpen(false); }}
|
onCancel={() => { setOpen(false); }}
|
||||||
|
afterOpenChange={visible => { if (visible) { nameInputRef.current?.focus(); } }}
|
||||||
width={1000}
|
width={1000}
|
||||||
footer={[
|
footer={[
|
||||||
<Button key="close" onClick={() => { setOpen(false); }}>
|
<Button key="close" onClick={() => { setOpen(false); }}>
|
||||||
@@ -349,7 +352,7 @@ function SearchModsButton() {
|
|||||||
initialValues={{ factorioVersion: factorioVersion, name: searchText }}
|
initialValues={{ factorioVersion: factorioVersion, name: searchText }}
|
||||||
>
|
>
|
||||||
<Form.Item name="name" label="Filter by Name or Title">
|
<Form.Item name="name" label="Filter by Name or Title">
|
||||||
<Input placeholder="Start typing to filter..." />
|
<Input ref={nameInputRef} placeholder="Start typing to filter..." />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="factorioVersion"
|
name="factorioVersion"
|
||||||
|
|||||||
Reference in new issue
Block a user