Having a similar problem, I was trying to apply some Custom CSS to a section that’s dynamically attached to a metaobject and everytime I made a change it would refresh the UI, but if the CSS wasn’t complete it would delete it - so basically I had to paste in the complete CSS for it to work.
**Edit, I misread this, this probably isn’t related
I think this issue is with a recent cli update…
Does your console return anything?
My problem/solution:
When running shopify dev I get the following error.
“The following Liquid files were updated locally and remotely”
Then listed a bunch of files.
I ran this command in terminal to normalize line endings:
find . -name “*.liquid” -type f -exec sed -i ‘’ ‘s/\r$//’ {} \;
”Removes carriage returns (\r) at the end of lines, converting:
CRLF (Windows: \r\n) → LF (Unix: \n)
So it normalizes line endings to Unix-style (LF).”
It seems that dev environment is auto refreshing anything that has these files in it causing this bug. When I ran the bug above it staged the exact files in the list from my error, but there was nothing appearing in the diff, but after pushing the changes I don’t have the issue anymore… but it seems I have to do this on every theme im working on.