Compare commits

..
Author SHA1 Message Date
Daniel 7060bf2c16 Merge pull request #1198 from bbassie/feature/mod-search-focus
Focus the mod search inputs when they open
2026-11-11 13:55:48 +01:00
bbassieandClaude Opus 5.5 3868efcead Focus the mod search inputs when they open
The "Add mods" card on the mod pack view mounts when shown, so autoFocus
is enough there. The Search Mod Portal modal stays mounted after the
first open, so it focuses the name input from afterOpenChange instead.

Fixes #1194

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:38:11 +00:00
3 changed files with 8 additions and 19 deletions

No files matched your search

@@ -182,6 +182,7 @@ function SearchModsTable(props: SearchModsTableProps) {
return <>
<Input
autoFocus
placeholder="Search Mods"
style={{ marginBottom: 8 }}
onChange={(event) => {
+6 -3
View File
@@ -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 {
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";
import {
ImportOutlined, PlusOutlined, SearchOutlined, DownloadOutlined,
@@ -147,6 +148,7 @@ function SearchModsButton() {
const account = useAccount();
const [open, setOpen] = useState(false);
const [form] = Form.useForm();
const nameInputRef = useRef<InputRef>(null);
const [searchText, setSearchText] = useState("");
const [factorioVersion, setFactorioVersion] = useState<lib.MajorMinorVersion>("2.0");
@@ -333,6 +335,7 @@ function SearchModsButton() {
title="Search Mod Portal"
open={open}
onCancel={() => { setOpen(false); }}
afterOpenChange={visible => { if (visible) { nameInputRef.current?.focus(); } }}
width={1000}
footer={[
<Button key="close" onClick={() => { setOpen(false); }}>
@@ -349,7 +352,7 @@ function SearchModsButton() {
initialValues={{ factorioVersion: factorioVersion, name: searchText }}
>
<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
name="factorioVersion"
+1 -16
View File
@@ -1271,23 +1271,8 @@ local function ensure_character(player)
player.teleport(force.get_spawn_position(planet_surface), planet_surface)
end
-- create_character needs a free spot within 200 tiles and does not generate chunks to find one. It fails in a chunk
-- which does not exist yet, such as one the player was teleported into a moment ago, and where water or void is all
-- there is. The character is then made at the force's spawn. From a missing chunk it is moved back, as the game
-- generates the chunks around a character. Otherwise there is nowhere to stand, and it stays at the spawn.
-- Create and return the character
if not player.create_character() then
surface = player.surface
local position = player.position
local force = player.force --[[@as LuaForce]]
local missing_chunk = not surface.is_chunk_generated({ math.floor(position.x / 32), math.floor(position.y / 32) })
player.teleport(force.get_spawn_position(surface), surface)
if player.create_character() and missing_chunk then
player.teleport(position, surface)
end
end
-- Return the character
if not player.character then
error(string.format(
"Failed to create character (controller: %s, physical: %s, surface: %s, connected: %s, driving: %s)",
controller_to_name[player.controller_type],