Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/sensitive-fields-mask-by-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@mobile-reality/mdma-renderer-react": patch
---

Fix sensitive form field masking in the default form renderer. Sensitive fields now start masked and
stay masked while typing (showing `•••`), instead of revealing the value as you type — the `👁`/`🔒`
toggle reveals it on demand. Also fixed the accompanying styles: masked inputs switch to
`type="password"`, which had no matching CSS rule and collapsed to an unstyled native box, and the
reveal/mask toggle button now sits as an overlay inside the input rather than wrapping onto its own
line below it.
7 changes: 2 additions & 5 deletions packages/renderer-react/src/components/FormRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function DefaultSensitiveIndicator({ label }: FormSensitiveIndicatorElementProps
// ─── Default sub-elements ────────────────────────────────────────────────────

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

return (
Expand All @@ -36,10 +36,7 @@ function DefaultInput({ id, type, value, onChange, required, sensitive }: FormIn
value={value}
required={required}
placeholder={sensitive ? `Enter ${type}...` : undefined}
onChange={(e) => {
onChange(e.target.value);
if (sensitive && masked) setMasked(false);
}}
onChange={(e) => onChange(e.target.value)}
/>
{sensitive && value && (
<button
Expand Down
45 changes: 45 additions & 0 deletions packages/renderer-react/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@

.mdma-form-field input[type="text"],
.mdma-form-field input[type="email"],
.mdma-form-field input[type="password"],
.mdma-form-field input[type="number"],
.mdma-form-field input[type="datetime"],
.mdma-form-field input[type="datetime-local"],
Expand Down Expand Up @@ -540,6 +541,50 @@
accent-color: var(--mdma-color-primary);
}

.mdma-input-wrapper {
display: flex;
align-items: center;
position: relative;
}

.mdma-input-wrapper input,
.mdma-input-wrapper textarea {
flex: 1;
padding-right: 36px;
}

.mdma-sensitive-toggle {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
cursor: pointer;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.04em;
color: var(--mdma-color-primary);
padding: 2px 4px;
opacity: 0.7;
transition: opacity 0.15s;
}

.mdma-sensitive-toggle:hover {
opacity: 1;
}

/* File inputs stack their file list below, so the wrapper is a column, not an overlay row. */
.mdma-input--file {
flex-direction: column;
align-items: flex-start;
gap: 8px;
}

.mdma-input--file input[type="file"] {
padding-right: 0;
}

.mdma-form-submit {
margin-top: 8px;
padding: 8px 20px;
Expand Down