SimpleIdServer icon indicating copy to clipboard operation
SimpleIdServer copied to clipboard

CSS Modifications Are Not Saved After Refresh

Open HappyRoot opened this issue 8 months ago • 2 comments

Hello,

When attempting to override existing CSS or add new styles, the changes do not persist after a page refresh.

Reproduction Steps:

  1. Navigate to the pwd form.
  2. Edit or add a CSS class in the stylesheet.
  3. Save
  4. 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.

HappyRoot avatar Jun 02 '25 09:06 HappyRoot

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);
        }
    }

HappyRoot avatar Jun 02 '25 13:06 HappyRoot

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

simpleidserver avatar Jun 02 '25 14:06 simpleidserver