Skip to content

Commit 0f019f5

Browse files
authored
Merge pull request #55 from MobileReality/fix/sensitive-rendering
fix: fixed rendering sensitive inputs
2 parents fab9cfa + 67f144a commit 0f019f5

3 files changed

Lines changed: 57 additions & 5 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@mobile-reality/mdma-renderer-react": patch
3+
---
4+
5+
Fix sensitive form field masking in the default form renderer. Sensitive fields now start masked and
6+
stay masked while typing (showing `•••`), instead of revealing the value as you type — the `👁`/`🔒`
7+
toggle reveals it on demand. Also fixed the accompanying styles: masked inputs switch to
8+
`type="password"`, which had no matching CSS rule and collapsed to an unstyled native box, and the
9+
reveal/mask toggle button now sits as an overlay inside the input rather than wrapping onto its own
10+
line below it.

packages/renderer-react/src/components/FormRenderer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function DefaultSensitiveIndicator({ label }: FormSensitiveIndicatorElementProps
2525
// ─── Default sub-elements ────────────────────────────────────────────────────
2626

2727
function DefaultInput({ id, type, value, onChange, required, sensitive }: FormInputElementProps) {
28-
const [masked, setMasked] = useState(sensitive === true && value !== '');
28+
const [masked, setMasked] = useState(sensitive === true);
2929
const displayType = masked ? 'password' : type;
3030

3131
return (
@@ -36,10 +36,7 @@ function DefaultInput({ id, type, value, onChange, required, sensitive }: FormIn
3636
value={value}
3737
required={required}
3838
placeholder={sensitive ? `Enter ${type}...` : undefined}
39-
onChange={(e) => {
40-
onChange(e.target.value);
41-
if (sensitive && masked) setMasked(false);
42-
}}
39+
onChange={(e) => onChange(e.target.value)}
4340
/>
4441
{sensitive && value && (
4542
<button

packages/renderer-react/styles.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@
506506

507507
.mdma-form-field input[type="text"],
508508
.mdma-form-field input[type="email"],
509+
.mdma-form-field input[type="password"],
509510
.mdma-form-field input[type="number"],
510511
.mdma-form-field input[type="datetime"],
511512
.mdma-form-field input[type="datetime-local"],
@@ -540,6 +541,50 @@
540541
accent-color: var(--mdma-color-primary);
541542
}
542543

544+
.mdma-input-wrapper {
545+
display: flex;
546+
align-items: center;
547+
position: relative;
548+
}
549+
550+
.mdma-input-wrapper input,
551+
.mdma-input-wrapper textarea {
552+
flex: 1;
553+
padding-right: 36px;
554+
}
555+
556+
.mdma-sensitive-toggle {
557+
position: absolute;
558+
right: 8px;
559+
top: 50%;
560+
transform: translateY(-50%);
561+
background: none;
562+
border: none;
563+
cursor: pointer;
564+
font-size: 11px;
565+
font-weight: 600;
566+
letter-spacing: 0.04em;
567+
color: var(--mdma-color-primary);
568+
padding: 2px 4px;
569+
opacity: 0.7;
570+
transition: opacity 0.15s;
571+
}
572+
573+
.mdma-sensitive-toggle:hover {
574+
opacity: 1;
575+
}
576+
577+
/* File inputs stack their file list below, so the wrapper is a column, not an overlay row. */
578+
.mdma-input--file {
579+
flex-direction: column;
580+
align-items: flex-start;
581+
gap: 8px;
582+
}
583+
584+
.mdma-input--file input[type="file"] {
585+
padding-right: 0;
586+
}
587+
543588
.mdma-form-submit {
544589
margin-top: 8px;
545590
padding: 8px 20px;

0 commit comments

Comments
 (0)