mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
fix: add missing id and name attributes to form input (#4589)
# Description of Changes - Updated `TextInput` component to require `id` and `name` props. - Passed `id` and `name` down to the underlying `<input>` element. - Updated `ToolSearch` component to provide explicit `id` and `name` for the search input. - This ensures form fields have unique identifiers, improving accessibility, browser autofill support, and form handling. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. Co-authored-by: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com>
This commit is contained in:
parent
3e9c55243e
commit
12d7165f83
@ -7,6 +7,10 @@ import styles from './textInput/TextInput.module.css';
|
|||||||
* Props for the TextInput component
|
* Props for the TextInput component
|
||||||
*/
|
*/
|
||||||
export interface TextInputProps {
|
export interface TextInputProps {
|
||||||
|
/** The input ID (required) */
|
||||||
|
id: string;
|
||||||
|
/** The input name (required) */
|
||||||
|
name: string;
|
||||||
/** The input value (required) */
|
/** The input value (required) */
|
||||||
value: string;
|
value: string;
|
||||||
/** Callback when input value changes (required) */
|
/** Callback when input value changes (required) */
|
||||||
@ -36,6 +40,8 @@ export interface TextInputProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(({
|
export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
placeholder,
|
placeholder,
|
||||||
@ -76,6 +82,8 @@ export const TextInput = forwardRef<HTMLInputElement, TextInputProps>(({
|
|||||||
<input
|
<input
|
||||||
ref={ref}
|
ref={ref}
|
||||||
type="text"
|
type="text"
|
||||||
|
id={id}
|
||||||
|
name={name}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => onChange(e.currentTarget.value)}
|
onChange={(e) => onChange(e.currentTarget.value)}
|
||||||
|
|||||||
@ -82,15 +82,17 @@ const ToolSearch = ({
|
|||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
const searchInput = (
|
const searchInput = (
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={searchRef}
|
id="tool-search-input"
|
||||||
value={value}
|
name="tool-search-input"
|
||||||
onChange={handleSearchChange}
|
ref={searchRef}
|
||||||
placeholder={placeholder || t("toolPicker.searchPlaceholder", "Search tools...")}
|
value={value}
|
||||||
icon={hideIcon ? undefined : <LocalIcon icon="search-rounded" width="1.5rem" height="1.5rem" />}
|
onChange={handleSearchChange}
|
||||||
autoComplete="off"
|
placeholder={placeholder || t("toolPicker.searchPlaceholder", "Search tools...")}
|
||||||
onFocus={onFocus}
|
icon={hideIcon ? undefined : <LocalIcon icon="search-rounded" width="1.5rem" height="1.5rem" />}
|
||||||
/>
|
autoComplete="off"
|
||||||
|
onFocus={onFocus}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mode === "filter") {
|
if (mode === "filter") {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user