Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Allow to change custom field type after creation, reusing create modal in web app (#2362)

Leendert de Borstc4091edfc5d0
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldLabel.razor b/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldLabel.razor
new file mode 100644
index 000000000..9eedbaef5
--- /dev/null
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldLabel.razor
@@ -0,0 +1,57 @@
+@using Microsoft.Extensions.Localization
+
+@inject IStringLocalizerFactory LocalizerFactory
+
+@* Label row for a custom field with edit and delete buttons. *@
+<div class="flex items-center gap-2 mb-2">
+ <label for="@HtmlFor" class="text-sm font-medium text-gray-900 dark:text-white">@Label</label>
+ <button type="button"
+ @onclick="OnEdit"
+ @onclick:preventDefault="true"
+ class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 text-xs"
+ title="@Localizer["EditLabel"]">
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
+ </svg>
+ </button>
+ @if (OnDelete.HasDelegate)
+ {
+ <button type="button"
+ @onclick="OnDelete"
+ @onclick:preventDefault="true"
+ class="text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 text-xs"
+ title="@Localizer["DeleteField"]">
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
+ </svg>
+ </button>
+ }
+</div>
+
+@code {
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Forms.EditableFieldLabel", "AliasVault.Client");
+
+ /// <summary>
+ /// Gets or sets the HTML for attribute to associate with the input.
+ /// </summary>
+ [Parameter]
+ public string HtmlFor { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the current label text.
+ /// </summary>
+ [Parameter]
+ public string Label { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the callback when the edit button is clicked.
+ /// </summary>
+ [Parameter]
+ public EventCallback OnEdit { get; set; }
+
+ /// <summary>
+ /// Gets or sets the callback when the delete button is clicked.
+ /// </summary>
+ [Parameter]
+ public EventCallback OnDelete { get; set; }
+}
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldModal.razor b/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldModal.razor
new file mode 100644
index 000000000..585b015bc
--- /dev/null
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/CustomFieldModal.razor
@@ -0,0 +1,139 @@
+@using AliasClientDb.Models
+@using Microsoft.Extensions.Localization
+
+@inject IStringLocalizerFactory LocalizerFactory
+@inject JsInteropService JsInteropService
+
+@* Modal for creating and editing a custom field. *@
+<FormModal
+ IsOpen="IsOpen"
+ Title="@(IsEditMode ? Localizer["EditCustomField"].Value : Localizer["AddCustomField"].Value)"
+ ConfirmText="@(IsEditMode ? SharedLocalizer["Save"].Value : Localizer["Add"].Value)"
+ CancelText="@Localizer["Cancel"]"
+ ConfirmButtonClass="bg-primary-600 hover:bg-primary-500 dark:bg-primary-700 dark:hover:bg-primary-600"
+ MaxWidth="md"
+ OnClose="OnClose"
+ OnConfirm="HandleConfirm">
+ <Icon>
+ <svg class="h-6 w-6 text-primary-600 dark:text-primary-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
+ </svg>
+ </Icon>
+ <ChildContent>
+ <div class="space-y-4">
+ <div>
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
+ @Localizer["FieldLabel"]
+ </label>
+ <input type="text"
+ id="custom-field-label-input"
+ @bind="Label"
+ @bind:event="oninput"
+ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:text-white"
+ placeholder="@Localizer["EnterFieldName"]" />
+ </div>
+ <div>
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
+ @Localizer["FieldType"]
+ </label>
+ <select @bind="SelectedFieldType"
+ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:text-white">
+ <option value="@FieldType.Text">@Localizer["FieldTypeText"]</option>
+ <option value="@FieldType.Password">@Localizer["FieldTypePassword"]</option>
+ <option value="@FieldType.Hidden">@Localizer["FieldTypeHidden"]</option>
+ <option value="@FieldType.TextArea">@Localizer["FieldTypeTextArea"]</option>
+ <option value="@FieldType.URL">@Localizer["FieldTypeUrl"]</option>
+ <option value="@FieldType.Email">@Localizer["FieldTypeEmail"]</option>
+ <option value="@FieldType.Phone">@Localizer["FieldTypePhone"]</option>
+ <option value="@FieldType.Number">@Localizer["FieldTypeNumber"]</option>
+ <option value="@FieldType.Date">@Localizer["FieldTypeDate"]</option>
+ </select>
+ </div>
+ </div>
+ </ChildContent>
+</FormModal>
+
+@code {
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Items.AddFieldMenu", "AliasVault.Client");
+
+ private IStringLocalizer SharedLocalizer => LocalizerFactory.Create("SharedResources", "AliasVault.Client");
+
+ /// <summary>
+ /// Gets or sets whether the modal is open.
+ /// </summary>
+ [Parameter]
+ public bool IsOpen { get; set; }
+
+ /// <summary>
+ /// Gets or sets whether an existing field is being edited (as opposed to a new one being added).
+ /// </summary>
+ [Parameter]
+ public bool IsEditMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the label the form is populated with when the modal opens.
+ /// </summary>
+ [Parameter]
+ public string InitialLabel { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the field type the form is populated with when the modal opens.
+ /// </summary>
+ [Parameter]
+ public string InitialFieldType { get; set; } = FieldType.Text;
+
+ /// <summary>
+ /// Gets or sets the callback invoked when the modal is dismissed.
+ /// </summary>
+ [Parameter]
+ public EventCallback OnClose { get; set; }
+
+ /// <summary>
+ /// Gets or sets the callback invoked with the submitted values. Parameters: (label, fieldType).
+ /// </summary>
+ [Parameter]
+ public EventCallback<(string Label, string FieldType)> OnSubmit { get; set; }
+
+ private string Label { get; set; } = string.Empty;
+ private string SelectedFieldType { get; set; } = FieldType.Text;
+ private bool _wasOpen;
+ private bool _shouldFocusInput;
+
+ /// <inheritdoc />
+ protected override void OnParametersSet()
+ {
+ // Reset the form to the field being edited (or to the defaults) whenever the modal opens.
+ if (IsOpen && !_wasOpen)
+ {
+ Label = InitialLabel;
+ SelectedFieldType = InitialFieldType;
+ _shouldFocusInput = true;
+ }
+
+ _wasOpen = IsOpen;
+ }
+
+ /// <inheritdoc />
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (!_shouldFocusInput)
+ {
+ return;
+ }
+
+ _shouldFocusInput = false;
+
+ // Wait for the modal to render, then focus and select the input text.
+ await Task.Delay(50);
+ await JsInteropService.FocusAndSelectElementById("custom-field-label-input");
+ }
+
+ private async Task HandleConfirm()
+ {
+ if (!string.IsNullOrWhiteSpace(Label))
+ {
+ await OnSubmit.InvokeAsync((Label.Trim(), SelectedFieldType));
+ await OnClose.InvokeAsync();
+ }
+ }
+}
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/DraggableCustomFieldsList.razor b/apps/server/AliasVault.Client/Main/Components/Forms/DraggableCustomFieldsList.razor
index 3abaf60c6..8072ff704 100644
--- a/apps/server/AliasVault.Client/Main/Components/Forms/DraggableCustomFieldsList.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/DraggableCustomFieldsList.razor
@@ -13,10 +13,10 @@
class="relative bg-white dark:bg-gray-800 rounded-lg group">
@* Draggable label row *@
<div class="cursor-grab active:cursor-grabbing">
- <EditableFieldLabel
+ <CustomFieldLabel
HtmlFor="@($"custom-{customField.TempId ?? customField.FieldKey}")"
Label="@customField.Label"
- LabelChanged="@((newLabel) => OnLabelChange.InvokeAsync((customField.FieldKey, newLabel)))"
+ OnEdit="@(() => StartEditing(customField))"
OnDelete="@(() => OnDelete.InvokeAsync(customField.FieldKey))"/>
</div>
@@ -67,6 +67,15 @@
}
</div>
+@* Custom Field Modal *@
+<CustomFieldModal
+ IsOpen="_editingField is not null"
+ IsEditMode="true"
+ InitialLabel="@(_editingField?.Label ?? string.Empty)"
+ InitialFieldType="@(_editingField?.FieldType ?? FieldType.Text)"
+ OnClose="StopEditing"
+ OnSubmit="HandleEditSubmit" />
+
@code {
private readonly string _containerId = $"draggable-fields-{Guid.NewGuid():N}";
private IJSObjectReference? _jsModule;
@@ -86,10 +95,10 @@
public EventCallback<List<SystemFieldEdit>> OnReorder { get; set; }
/// <summary>
- /// Event callback when a field label is changed.
+ /// Event callback when a field's label or type is changed.
/// </summary>
[Parameter]
- public EventCallback<(string fieldKey, string newLabel)> OnLabelChange { get; set; }
+ public EventCallback<(string fieldKey, string label, string fieldType)> OnFieldUpdate { get; set; }
/// <summary>
/// Event callback when a field is deleted.
@@ -98,6 +107,25 @@
public EventCallback<string> OnDelete { get; set; }
private int _lastFieldCount;
+ private SystemFieldEdit? _editingField;
+
+ private void StartEditing(SystemFieldEdit customField)
+ {
+ _editingField = customField;
+ }
+
+ private void StopEditing()
+ {
+ _editingField = null;
+ }
+
+ private async Task HandleEditSubmit((string Label, string FieldType) args)
+ {
+ if (_editingField is not null)
+ {
+ await OnFieldUpdate.InvokeAsync((_editingField.FieldKey, args.Label, args.FieldType));
+ }
+ }
/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/EditableFieldLabel.razor b/apps/server/AliasVault.Client/Main/Components/Forms/EditableFieldLabel.razor
deleted file mode 100644
index 1e631b75a..000000000
--- a/apps/server/AliasVault.Client/Main/Components/Forms/EditableFieldLabel.razor
+++ /dev/null
@@ -1,126 +0,0 @@
-@using Microsoft.Extensions.Localization
-
-@inject IStringLocalizerFactory LocalizerFactory
-
-@if (IsEditing)
-{
- <div class="flex items-center gap-2 mb-2">
- <input type="text"
- @bind="EditValue"
- @bind:event="oninput"
- @onkeydown="HandleKeyDown"
- @onblur="HandleSave"
- class="flex-1 px-2 py-1 text-sm font-medium text-gray-900 dark:text-white border border-primary-500 rounded focus:outline-none focus:ring-1 focus:ring-primary-500 dark:bg-gray-700 dark:border-primary-400"
- placeholder="@Localizer["FieldLabelPlaceholder"]"
- @ref="EditInputRef" />
- <button type="button"
- @onclick="HandleSave"
- @onclick:preventDefault="true"
- class="text-green-600 dark:text-green-400 hover:text-green-700 dark:hover:text-green-300 text-xs px-2 py-1">
- ✓
- </button>
- <button type="button"
- @onclick="HandleCancel"
- @onclick:preventDefault="true"
- class="text-gray-600 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 text-xs px-2 py-1">
- ✕
- </button>
- </div>
-}
-else
-{
- <div class="flex items-center gap-2 mb-2">
- <label for="@HtmlFor" class="text-sm font-medium text-gray-900 dark:text-white">@Label</label>
- <button type="button"
- @onclick="StartEditing"
- @onclick:preventDefault="true"
- class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 text-xs"
- title="@Localizer["EditLabel"]">
- <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
- </svg>
- </button>
- @if (OnDelete.HasDelegate)
- {
- <button type="button"
- @onclick="HandleDelete"
- @onclick:preventDefault="true"
- class="text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 text-xs"
- title="@Localizer["DeleteField"]">
- <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
- </svg>
- </button>
- }
- </div>
-}
-
-@code {
- private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Forms.EditableFieldLabel", "AliasVault.Client");
-
- /// <summary>
- /// Gets or sets the HTML for attribute to associate with the input.
- /// </summary>
- [Parameter]
- public string HtmlFor { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the current label text.
- /// </summary>
- [Parameter]
- public string Label { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the callback when the label changes.
- /// </summary>
- [Parameter]
- public EventCallback<string> LabelChanged { get; set; }
-
- /// <summary>
- /// Gets or sets the callback when the delete button is clicked.
- /// </summary>
- [Parameter]
- public EventCallback OnDelete { get; set; }
-
- private bool IsEditing { get; set; }
- private string EditValue { get; set; } = string.Empty;
- private ElementReference EditInputRef;
-
- private void StartEditing()
- {
- EditValue = Label;
- IsEditing = true;
- }
-
- private async Task HandleSave()
- {
- if (!string.IsNullOrWhiteSpace(EditValue))
- {
- await LabelChanged.InvokeAsync(EditValue.Trim());
- }
- IsEditing = false;
- }
-
- private void HandleCancel()
- {
- EditValue = Label;
- IsEditing = false;
- }
-
- private async Task HandleKeyDown(KeyboardEventArgs e)
- {
- if (e.Key == "Enter")
- {
- await HandleSave();
- }
- else if (e.Key == "Escape")
- {
- HandleCancel();
- }
- }
-
- private async Task HandleDelete()
- {
- await OnDelete.InvokeAsync();
- }
-}
diff --git a/apps/server/AliasVault.Client/Main/Components/Items/AddFieldMenu.razor b/apps/server/AliasVault.Client/Main/Components/Items/AddFieldMenu.razor
index 1d029bb8a..af811fbd7 100644
--- a/apps/server/AliasVault.Client/Main/Components/Items/AddFieldMenu.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Items/AddFieldMenu.razor
@@ -1,10 +1,8 @@
@using AliasClientDb.Models
-@using AliasVault.Client.Main.Components.Layout
-@using AliasVault.Client.Services.JsInterop
+@using AliasVault.Client.Main.Components.Forms
@using Microsoft.Extensions.Localization
@inject IStringLocalizerFactory LocalizerFactory
-@inject JsInteropService JsInteropService
<div class="relative">
<button type="button"
@@ -82,53 +80,11 @@
</div>
@* Custom Field Modal *@
-<FormModal
+<CustomFieldModal
IsOpen="ShowCustomFieldModal"
- Title="@Localizer["AddCustomField"]"
- ConfirmText="@Localizer["Add"]"
- CancelText="@Localizer["Cancel"]"
- ConfirmButtonClass="bg-primary-600 hover:bg-primary-500 dark:bg-primary-700 dark:hover:bg-primary-600"
- MaxWidth="md"
+ InitialLabel="@CustomFieldLabel"
OnClose="CloseCustomFieldModal"
- OnConfirm="HandleAddCustomField">
- <Icon>
- <svg class="h-6 w-6 text-primary-600 dark:text-primary-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
- </svg>
- </Icon>
- <ChildContent>
- <div class="space-y-4">
- <div>
- <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
- @Localizer["FieldLabel"]
- </label>
- <input type="text"
- id="custom-field-label-input"
- @bind="CustomFieldLabel"
- @bind:event="oninput"
- class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:text-white"
- placeholder="@Localizer["EnterFieldName"]" />
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
- @Localizer["FieldType"]
- </label>
- <select @bind="CustomFieldType"
- class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:text-white">
- <option value="Text">@Localizer["FieldTypeText"]</option>
- <option value="Password">@Localizer["FieldTypePassword"]</option>
- <option value="Hidden">@Localizer["FieldTypeHidden"]</option>
- <option value="Email">@Localizer["FieldTypeEmail"]</option>
- <option value="URL">@Localizer["FieldTypeUrl"]</option>
- <option value="Phone">@Localizer["FieldTypePhone"]</option>
- <option value="Number">@Localizer["FieldTypeNumber"]</option>
- <option value="Date">@Localizer["FieldTypeDate"]</option>
- <option value="TextArea">@Localizer["FieldTypeTextArea"]</option>
- </select>
- </div>
- </div>
- </ChildContent>
-</FormModal>
+ OnSubmit="OnAddCustomField" />
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Items.AddFieldMenu", "AliasVault.Client");
@@ -196,7 +152,6 @@
private bool IsOpen { get; set; }
private bool ShowCustomFieldModal { get; set; }
private string CustomFieldLabel { get; set; } = string.Empty;
- private string CustomFieldType { get; set; } = "Text";
private void ToggleMenu()
{
@@ -226,34 +181,18 @@
CloseMenu();
}
- private async Task OpenCustomFieldModal()
+ private void OpenCustomFieldModal()
{
ShowCustomFieldModal = true;
// Auto-generate a default label based on existing custom field count
CustomFieldLabel = string.Format(Localizer["DefaultFieldLabel"].Value, CustomFieldCount + 1);
- CustomFieldType = "Text";
CloseMenu();
-
- // Wait for the modal to render, then focus and select the input text
- await Task.Delay(50);
- await JsInteropService.FocusAndSelectElementById("custom-field-label-input");
}
- private Task CloseCustomFieldModal()
+ private void CloseCustomFieldModal()
{
ShowCustomFieldModal = false;
CustomFieldLabel = string.Empty;
- CustomFieldType = "Text";
- return Task.CompletedTask;
- }
-
- private async Task HandleAddCustomField()
- {
- if (!string.IsNullOrWhiteSpace(CustomFieldLabel))
- {
- await OnAddCustomField.InvokeAsync((CustomFieldLabel.Trim(), CustomFieldType));
- await CloseCustomFieldModal();
- }
}
private string GetFieldLabel(string fieldKey)
diff --git a/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs b/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
index 64f8c3300..5056da9ae 100644
--- a/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
+++ b/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
@@ -485,16 +485,19 @@ public sealed class ItemEdit
}
/// <summary>
- /// Updates the label of a custom field.
+ /// Updates the label and type of a custom field.
/// </summary>
/// <param name="fieldKey">The field key.</param>
- /// <param name="newLabel">The new label.</param>
- public void UpdateCustomFieldLabel(string fieldKey, string newLabel)
+ /// <param name="label">The new label.</param>
+ /// <param name="fieldType">The new field type.</param>
+ public void UpdateCustomField(string fieldKey, string label, string fieldType)
{
var field = Fields.FirstOrDefault(f => f.FieldKey == fieldKey && f.IsCustomField);
if (field != null)
{
- field.Label = newLabel;
+ field.Label = label;
+ field.FieldType = fieldType;
+ field.IsHidden = fieldType == FieldType.Hidden || fieldType == FieldType.Password;
}
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
index 6eb1d1c3c..bf14deb44 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
@@ -359,7 +359,7 @@ else
<DraggableCustomFieldsList
CustomFields="@customFields"
OnReorder="HandleCustomFieldsReorder"
- OnLabelChange="HandleCustomFieldLabelChange"
+ OnFieldUpdate="HandleCustomFieldUpdate"
OnDelete="HandleCustomFieldDelete" />
</div>
</div>
@@ -804,11 +804,11 @@ else
}
/// <summary>
- /// Handles custom field label change from the draggable list.
+ /// Handles custom field label and type changes from the draggable list.
/// </summary>
- private void HandleCustomFieldLabelChange((string fieldKey, string newLabel) args)
+ private void HandleCustomFieldUpdate((string fieldKey, string label, string fieldType) args)
{
- Obj.UpdateCustomFieldLabel(args.fieldKey, args.newLabel);
+ Obj.UpdateCustomField(args.fieldKey, args.label, args.fieldType);
StateHasChanged();
}
diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Items/AddFieldMenu.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Items/AddFieldMenu.en.resx
index ac7fc7573..db494bda5 100644
--- a/apps/server/AliasVault.Client/Resources/Components/Main/Items/AddFieldMenu.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Items/AddFieldMenu.en.resx
@@ -97,6 +97,10 @@
</data>
<!-- Custom field modal -->
+ <data name="EditCustomField">
+ <value>Edit Custom Field</value>
+ <comment>Title of the modal when editing an existing custom field</comment>
+ </data>
<data name="FieldLabel">
<value>Field Label</value>
<comment>Label for field label input</comment>
diff --git a/apps/server/AliasVault.Client/Services/ItemService.cs b/apps/server/AliasVault.Client/Services/ItemService.cs
index 097d14a51..853c423b7 100644
--- a/apps/server/AliasVault.Client/Services/ItemService.cs
+++ b/apps/server/AliasVault.Client/Services/ItemService.cs
@@ -1200,12 +1200,16 @@ public sealed class ItemService(HttpClient httpClient, DbService dbService, Conf
existingField.UpdatedAt = updateDateTime;
}
- // Also update the FieldDefinition label if it has changed
+ // Also update the FieldDefinition if its label, type or hidden state has changed
if (newField.FieldDefinition != null && existingField.FieldDefinition != null)
{
- if (existingField.FieldDefinition.Label != newField.FieldDefinition.Label)
+ if (existingField.FieldDefinition.Label != newField.FieldDefinition.Label ||
+ existingField.FieldDefinition.FieldType != newField.FieldDefinition.FieldType ||
+ existingField.FieldDefinition.IsHidden != newField.FieldDefinition.IsHidden)
{
existingField.FieldDefinition.Label = newField.FieldDefinition.Label;
+ existingField.FieldDefinition.FieldType = newField.FieldDefinition.FieldType;
+ existingField.FieldDefinition.IsHidden = newField.FieldDefinition.IsHidden;
existingField.FieldDefinition.UpdatedAt = updateDateTime;
}
}