Fix input field value when switching login method by setting keys

This commit is contained in:
RaffaelW 2026-01-31 21:43:56 +01:00
parent 0b8020d06d
commit 3b05b6fe54

View file

@ -165,6 +165,7 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
// Show fields depending on selected login method // Show fields depending on selected login method
if (_method == LoginMethod.credentials) ...[ if (_method == LoginMethod.credentials) ...[
TextFormField( TextFormField(
key: ValueKey("input-username"),
decoration: InputDecoration( decoration: InputDecoration(
labelText: L10().username, labelText: L10().username,
labelStyle: TextStyle(fontWeight: FontWeight.bold), labelStyle: TextStyle(fontWeight: FontWeight.bold),
@ -184,6 +185,7 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
}, },
), ),
TextFormField( TextFormField(
key: ValueKey("input-password"),
decoration: InputDecoration( decoration: InputDecoration(
labelText: L10().password, labelText: L10().password,
labelStyle: TextStyle(fontWeight: FontWeight.bold), labelStyle: TextStyle(fontWeight: FontWeight.bold),
@ -215,6 +217,7 @@ class _InvenTreeLoginState extends State<InvenTreeLoginWidget> {
), ),
] else ...[ ] else ...[
TextFormField( TextFormField(
key: ValueKey("input-token"),
decoration: InputDecoration( decoration: InputDecoration(
labelText: L10().token, labelText: L10().token,
labelStyle: TextStyle(fontWeight: FontWeight.bold), labelStyle: TextStyle(fontWeight: FontWeight.bold),