CSS Modifications Are Not Saved After Refresh
Hello,
When attempting to override existing CSS or add new styles, the changes do not persist after a page refresh.
Reproduction Steps:
- Navigate to the pwd form.
- Edit or add a CSS class in the stylesheet.
- Save
- Reload the page.
Expected Result:
The updated styles should remain applied.
Observed Result:
The styles revert to their original state upon refresh.
The same behavior occurs in the live demo version, confirming it is not environment-specific.
Issue identified: In TemplateStore, the ITemplateStore (DbContext) fails to track changes because the modified field is a JSON string. This causes CSS changes to reset on page reload.
Fix: Need to ensure proper change tracking for JSON fields in the DbContext
TemplatesController : BaseController
[HttpPut]
public async Task<IActionResult> Update([FromRoute] string prefix, string id, [FromBody] FormBuilder.Models.Template template, CancellationToken cancellationToken)
{
prefix = prefix ?? Constants.DefaultRealm;
try
{
await CheckAccessToken(prefix, Config.DefaultScopes.Templates.Name);
var existingTemplate = await _templateStore.Get(id, cancellationToken);
if (existingTemplate == null)
{
return new NotFoundResult();
}
foreach (var s in template.Styles)
{
var existingStyle = existingTemplate.Styles.Single(st => st.Id == s.Id);
if (existingStyle != null)
{
existingStyle.Value = s.Value;
}
}
existingTemplate.Windows = template.Windows;
existingTemplate.Elements = template.Elements;
var res = await _templateStore.SaveChanges(cancellationToken);
return new NoContentResult();
}
catch (Exception ex)
{
_logger.LogError(ex.ToString());
return BuildError(ex);
}
}
Hello,
You're right — there is indeed an issue in the code. I've made some modifications in the release/v6.0.3 branch to fix it.
Kind regards, SID