Skip to content

Commit aaa4add

Browse files
committed
Update Input.tsx
1 parent b2684b4 commit aaa4add

File tree

1 file changed

+19
-14
lines changed
  • packages/gitbook/src/components/primitives

1 file changed

+19
-14
lines changed

packages/gitbook/src/components/primitives/Input.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ export const Input = React.forwardRef<HTMLInputElement | HTMLTextAreaElement, In
102102
}
103103
onChange?.(event);
104104

105+
// Reset submitted state when user edits the value to allow re-submission
106+
if (submitted) {
107+
setSubmitted(false);
108+
}
109+
105110
if (multiline && resize && 'current' in ref && ref.current) {
106111
ref.current.style.height = 'auto';
107112
ref.current.style.height = `${ref.current.scrollHeight}px`;
@@ -166,10 +171,12 @@ export const Input = React.forwardRef<HTMLInputElement | HTMLTextAreaElement, In
166171
<div
167172
className={tcls(
168173
'group/input relative flex min-h-min gap-2 overflow-hidden border border-tint bg-tint-base shadow-tint/6 ring-primary-hover transition-all dark:shadow-tint-1',
169-
'depth-subtle:focus-within:-translate-y-px depth-subtle:hover:-translate-y-px depth-subtle:shadow-sm depth-subtle:focus-within:shadow-lg',
170174
disabled
171-
? 'cursor-not-allowed border-tint-subtle bg-tint-subtle'
172-
: 'focus-within:border-primary-hover focus-within:shadow-primary-subtle focus-within:ring-2 hover:cursor-text hover:border-tint-hover focus-within:hover:border-primary-hover',
175+
? 'cursor-not-allowed border-tint-subtle bg-tint-subtle opacity-7'
176+
: [
177+
'depth-subtle:focus-within:-translate-y-px depth-subtle:hover:-translate-y-px depth-subtle:shadow-xs',
178+
'focus-within:border-primary-hover focus-within:depth-subtle:shadow-lg focus-within:shadow-primary-subtle focus-within:ring-2 hover:cursor-text hover:border-tint-hover depth-subtle:hover:not-focus-within:shadow-md focus-within:hover:border-primary-hover',
179+
],
173180
multiline ? 'flex-col' : 'flex-row',
174181
ariaBusy ? 'cursor-progress' : '',
175182
SIZE_CLASSES[sizing].container,
@@ -255,17 +262,15 @@ export const Input = React.forwardRef<HTMLInputElement | HTMLTextAreaElement, In
255262
{value.toString().length} / {maxLength}
256263
</span>
257264
) : null}
258-
{submitted ? (
259-
submitMessage ? (
260-
typeof submitMessage === 'string' ? (
261-
<div className="ml-auto flex animate-fade-in items-center gap-1 p-1.5 text-success-subtle">
262-
<Icon icon="check-circle" className="size-4" />
263-
{submitMessage}
264-
</div>
265-
) : (
266-
submitMessage
267-
)
268-
) : null
265+
{submitted && submitMessage ? (
266+
typeof submitMessage === 'string' ? (
267+
<div className="ml-auto flex animate-fade-in items-center gap-1 p-1.5 text-success-subtle">
268+
<Icon icon="check-circle" className="size-4" />
269+
{submitMessage}
270+
</div>
271+
) : (
272+
submitMessage
273+
)
269274
) : submitButton ? (
270275
<Button
271276
variant="primary"

0 commit comments

Comments
 (0)