Problem

When a CSS style is added and saved in the Stylify module, the style is applied
correctly and the visual change is immediately reflected on the page. However,
after refreshing the page, the saved style is no longer present and the visual
change is reverted.

Steps to Reproduce

  1. Install and enable the Stylify module.
  2. Open the Stylify editor.
  3. Add the following CSS:
    body {
      background: red;
    }
  4. Save the style.
  5. Observe the page.

Actual result:

The page background changes to red immediately after saving.

  1. Refresh/reload the page.
  2. Open the Stylify editor again and check the saved styles.

Actual Result

The CSS style:

body {
  background: red;
}

is removed after the page refresh, and the background color returns to its
previous state.

Expected Result

The saved CSS should persist after a page refresh and continue to be applied
to the page.

Impact

Users may believe their styles have been successfully saved because the
changes are visible immediately after saving. However, the styles are lost
after refreshing the page, resulting in data loss and unexpected
visual regressions
.

Environment

  • Drupal version: 10.6
  • Stylify version: 1.0.0
  • PHP version: 8.4
  • Browser: google Chrome
  • Theme: Olivero 10.6.13
  • Multilingual configuration: Yes

Additional Information

The issue appears to be related to the persistence of styles after the save
operation. The style is successfully applied during the current session but
does not persist after a page reload.

This should be investigated to determine whether the style is not being
persisted correctly, is being removed during the subsequent page load, or is
not being retrieved correctly from storage.

Issue fork stylify-3619216

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

yogesh045 created an issue. See original summary.

shardashukla’s picture

Assigned: Unassigned » shardashukla
yogesh045’s picture

Issue summary: View changes

shardashukla’s picture

Priority: Major » Normal
Status: Active » Needs review

Fix saved CSS not persisting after page refresh
closes this #3619216

yogesh045’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and tested MR !4.

Testing performed:

Reproduced the original issue where saved CSS was applied immediately but disappeared after a page refresh.
Tested MR !4 with the following CSS:
body {
background: red;
}

  1. Confirmed the style is applied immediately after saving.
  2. Confirmed the style persists after refreshing the page.
  3. Reopened the Stylify editor after refresh and confirmed the saved CSS is still present.
  4. Tested updating the saved CSS and confirmed the updated value persists after refresh.
  5. Reviewed the changes in MR !4 and found the implementation addresses the reported persistence issue.
  6. No regressions were observed during testing.