Skip to content

Commit 0c07e10

Browse files
Leonabcd123fehmer
andauthored
impr(input-indicator): add input indicator to all fields with validators (@Leonabcd123) (#7918)
Remove the `showIndicator` property from `InputField`, instead check whether `validators` exists to decide whether we should show the input indicator. --------- Co-authored-by: Christian Fehmer <fehmer@users.noreply.github.com>
1 parent 2ddecef commit 0c07e10

5 files changed

Lines changed: 4 additions & 15 deletions

File tree

frontend/__tests__/components/ui/form/InputField.spec.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,10 @@ describe("InputField", () => {
8383
expect(screen.getByRole("textbox")).toBeDisabled();
8484
});
8585

86-
it("shows FieldIndicator when showIndicator is true", () => {
86+
it("shows FieldIndicator", () => {
8787
const field = makeField("name");
8888
field.state.meta.isValidating = true;
89-
const { container } = render(() => (
90-
<InputField field={() => field} showIndicator />
91-
));
89+
const { container } = render(() => <InputField field={() => field} />);
9290

9391
expect(container.querySelector(".fa-circle-notch")).toBeInTheDocument();
9492
});

frontend/src/ts/components/pages/login/Register.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export function Register(): JSXElement {
166166
<InputField
167167
field={field}
168168
placeholder="username"
169-
showIndicator
170169
autocomplete="new-username"
171170
disabled={!getLoginPageInputsEnabled()}
172171
/>
@@ -187,7 +186,6 @@ export function Register(): JSXElement {
187186
<InputField
188187
field={field}
189188
placeholder="email"
190-
showIndicator
191189
autocomplete="new-email"
192190
disabled={!getLoginPageInputsEnabled()}
193191
onFocus={() => {
@@ -214,7 +212,6 @@ export function Register(): JSXElement {
214212
children={(field) => (
215213
<InputField
216214
field={field}
217-
showIndicator
218215
autocomplete="verify-email"
219216
placeholder="verify email"
220217
disabled={!getLoginPageInputsEnabled()}
@@ -238,7 +235,6 @@ export function Register(): JSXElement {
238235
<InputField
239236
field={field}
240237
placeholder="password"
241-
showIndicator
242238
autocomplete="new-password"
243239
type="password"
244240
disabled={!getLoginPageInputsEnabled()}
@@ -256,7 +252,6 @@ export function Register(): JSXElement {
256252
children={(field) => (
257253
<InputField
258254
field={field}
259-
showIndicator
260255
placeholder="verify password"
261256
autocomplete="verify-password"
262257
type="password"

frontend/src/ts/components/pages/profile/ProfileSearchPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export function ProfileSearchPage(): JSXElement {
8686
<InputField
8787
field={field}
8888
placeholder="username"
89-
showIndicator
9089
autocomplete="new-username"
9190
disabled={!isEditable()}
9291
/>

frontend/src/ts/components/ui/form/InputField.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { FieldIndicator } from "./FieldIndicator";
77
export function InputField(props: {
88
field: Accessor<AnyFieldApi>;
99
placeholder?: string;
10-
showIndicator?: boolean;
1110
autocomplete?: string;
1211
type?: string;
1312
disabled?: boolean;
@@ -24,7 +23,7 @@ export function InputField(props: {
2423
"rounded border-none bg-sub-alt p-[0.5em] text-em-base leading-[1.25em] caret-main outline-none",
2524
"focus-visible:shadow-[0_0_0_0.1rem_var(--bg-color),0_0_0_0.2rem_var(--text-color)]",
2625
"autofill-fix",
27-
props.showIndicator === true ? "pr-[1.85em]" : "",
26+
props.field().options.validators ? "pr-[1.85em]" : "",
2827
props.class,
2928
)}
3029
type={props.type ?? "text"}
@@ -40,7 +39,7 @@ export function InputField(props: {
4039
dir={props.dir}
4140
maxLength={props.maxLength}
4241
/>
43-
<Show when={props.showIndicator}>
42+
<Show when={props.field().options.validators}>
4443
<FieldIndicator field={props.field()} />
4544
</Show>
4645
</div>

frontend/storybook/stories/Form.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export const withValidation = meta.story({
6464
children={(field) => (
6565
<InputField
6666
field={field}
67-
showIndicator
6867
autocomplete="current-user"
6968
disabled={!isEditable()}
7069
/>
@@ -79,7 +78,6 @@ export const withValidation = meta.story({
7978
<InputField
8079
field={field}
8180
type="password"
82-
showIndicator
8381
autocomplete="current-password"
8482
disabled={!isEditable()}
8583
/>

0 commit comments

Comments
 (0)