text_field: secure: true for masked password input - #12
Closed
C-Sinclair wants to merge 1 commit into
Closed
Conversation
Adds a `secure: true` prop to `text_field`. iOS swaps the underlying
SwiftUI control from `TextField` to `SecureField` when the prop is
set; cleartext still reaches the BEAM via `on_change` so apps can
hash/store the value normally. The prop is a plain pass-through
through `Mob.Renderer.prepare_props/4` — unknown atoms-as-values
already serialise as-is — so no renderer changes were needed.
Android consumes the same prop via `PasswordVisualTransformation` once
mob_new's `MobBridge.kt.eex` template is updated in a companion PR.
Until then `secure: true` is a graceful no-op on Android — the prop
travels but the Compose `TextField` ignores it (regular field, no
breakage).
Reveal-toggle ("eye" button) is intentionally deferred. The iOS
implementation needs `ZStack`-and-opacity to retain focus across
SecureField/TextField swaps (a plain if/else tears down the field,
dropping focus + dismissing the keyboard on every toggle). Worth its
own PR with the matching Compose `trailingIcon` slot wired up.
CHANGELOG entry lands under [Unreleased] — version bump rides along
with the next release commit per the repo's pattern.
C-Sinclair
force-pushed
the
text-field-secure
branch
from
May 18, 2026 15:44
70ee1b6 to
1e2ce92
Compare
This was referenced May 18, 2026
Owner
|
Thanks @C-Sinclair — landed as 290254b in mob 0.6.15 with your authorship preserved. Paired with mob_new#6 (Android Compose side) landed as 4a41f47 in mob_new 0.3.8, so CHANGELOG entries merged into the new [0.6.15] block (and mob_new [0.3.8]). Closing since the commit is on master. |
pshoukry
pushed a commit
to pshoukry/mob
that referenced
this pull request
Sep 9, 2026
…ixed (mob_new + mob_dev companion commits) Four small lost-in-the-shuffle items closed in this batch. All four were held up by Phase 2 work touching the same files (GenericJam#1/GenericJam#2/GenericJam#4 in live_view_patcher.ex; GenericJam#5 in native_build.ex). GenericJam#1 — Phoenix LiveReload mac_listener warnings: code_reloader/watchers/ live_reload disabled in on-device endpoint config. GenericJam#2 — esbuild/tailwind version-not-configured warnings: versions set via Application.put_env in mob_app.ex before ensure_all_started. GenericJam#4 — port 4200 collisions across multiple Mob LV apps: per-app hash into 4200..4999 via :erlang.phash2(:<app>, 800). GenericJam#5 — deploy auto-pick of iPhone over sim was silent: prints the --device <short-id> alternative when both are connected. GenericJam#3 (WS→longpoll fallback in WKWebView) is investigation, not a fix — deferred. GenericJam#6-GenericJam#11 are larger work (OTP rebuild, AX modifiers, Compose semantics walker, Android 17 SELinux patch). GenericJam#12, GenericJam#13 already fixed earlier. GenericJam#14 is moderate — sim node naming reconciliation between mob_dev's connect.ex and mob_beam.m, deferred.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
secure: trueprop totext_field. iOS renders the field as a SwiftUISecureField(masked input) instead ofTextField. Cleartext still reaches the BEAM viaon_change— apps hash/store the value as normal.The prop flows through
Mob.Renderer.prepare_props/4's generic pass-through; no renderer changes were needed. Native side:MobNode.isSecureBOOL, parsed inmob_nif.m, branched on inMobRootView.swiftvia a@ViewBuilderfield switch.Version / CHANGELOG
CHANGELOG entry under
## [Unreleased]; nomix.exsbump. Matches the repo's pattern of feature-commits-without-bumps and a separate ride-alongBump to X.Y.Zcommit at release-cut time (e.g. b974398).Android
This PR is iOS-only. Mob's library doesn't own Android Compose UI — that lives per-app, generated from
mob_new'sMobBridge.kt.eextemplate. A companion PR against GenericJam/mob_new addsPasswordVisualTransformation+KeyboardType.Passwordto the template.Until that ships,
secure: trueis a graceful no-op on Android: the prop travels through the renderer but the ComposeTextFieldignores it. No breakage for unpatched apps.Why no reveal-toggle ("eye" button) yet
Worth its own PR. The iOS implementation needs
ZStack-and-opacity to retain focus acrossSecureField/TextFieldswaps — the current@ViewBuilder if/else(and any naive toggle) tears the view down on every flip, dropping focus and dismissing the keyboard. Pairs with atrailingIconslot in Compose. Out of scope here.Test plan
mix test— 794 passed (27 doctests, 767 tests), 43 excluded. Two new renderer tests coversecure: trueserialising and absence-by-default.mix format --check-formatted— cleanmix credo --strict— clean (949 mods/funs, 0 issues)mix compile --warnings-as-errors— cleanmix erlfmt --check src/— cleanxcrun clang-format --dry-run -Werror ios/*.m ios/*.h— cleanSecureFieldrenders dots; BEAM:passwordassign holds cleartext ("hunter2");Length: 7label updates live.MobBridge.ktpatch applied locally: dots render, cleartext reaches BEAM, length label updates. (Template patch lands in the mob_new companion PR.)swiftlint ios/— not installed locally; the Swift diff is mechanical (single expression swapped for an@ViewBuildercomputed property).Files
ios/MobNode.h—@property(nonatomic, assign) BOOL isSecureios/mob_nif.m— parsesprops[@"secure"]alongsidekeyboard/return_keyios/MobRootView.swift—@ViewBuilder var fieldpicksSecureFieldorTextField; existing modifier chain applies uniformly to bothtest/mob/renderer_test.exs— pass-through and default-absent testsCHANGELOG.md— entry under## [Unreleased]