Overwriting a property manually on an Instance that is being overwritten by StyleRule, permanently unlinks that property from StyleRule

Info

System: Windows 10 - 64bit
Studio Version: Version 0.614.0.6140412 (64bit)

Description

The bug, is that when you save the game. It will also save that what the StyleRules are modifying, and then it won’t modify them anymore.

Below is a clarification. Overwriting a property manually on an Instance that is being overwritten by StyleRule, permanently unlinks that property from StyleRule - #3 by HealthyKarl

Overwriting a property manually on an Instance that is being overwritten by StyleRule, permanently unlinks that property from StyleRule.

e.g. a TextLabel is listening to a StyleRule, which changes the BackgroundColor3 property.
However, if you However, saving the game overwrites the BackgroundColor3 property on the TextLabel, and the StyleRule will no longer apply the BackgroundColor3 on it, doesn’t matter what you do. You’re forced to destroy the TextLabel and create an entire new one through a Script, which doesn’t touch the BackgroundColor3 property.

Loading any save file, destroys any links from StyleRule. I believe the reason for that is

  • You Load a save file
  • It initializes Instances, such as their Colors and seems to set the Color property ontop in its own Object again
  • Then StyleRule doesn’t work on it.

The Reproduction Steps and rest below are not updated, see the comment below this Overwriting a property manually on an Instance that is being overwritten by StyleRule, permanently unlinks that property from StyleRule - #3 by HealthyKarl

Reproduction Steps

Before you start you need the following Fast Flags.

  • {"FFlagEnableStylingEverywhere":true}

 

  1. Get this game:
    bug_repro_stylerule_overwrite.rbxlx (74.4 KB)

  2. Copy paste this code into the console

local TextLabel = Instance.new("TextLabel")
TextLabel.Size = UDim2.new(0.5, 0, 0.5, 0)
TextLabel.Position = UDim2.new(0.25, 0, 0.1707921, 0)

TextLabel.Parent = game:GetService("StarterGui").ScreenGui

TextLabel:AddTag("ControlColor")

  1. Go to .ControlColor and use the Color Picker from the Attribute.
  2. You will notice that the Color changes with the TextLabel’s BackgroundColor3 _(which is intended)
  3. Go to the TextLabel and change the Color Property manually

Now the Color of the TextLabel is no longer synced with StyleRule, doesn’t matter if you re-link the StyleLink. The TextLabel needs to be destroyed and created again.

OR

Run the scripts in these, by copy pasting them into the console
image

Expected Result

That the StyleRule still overrides the color, regardless of TextLabel overriding the color on its own. (well, HTML AND CSS has inline style rule, but this one can’t be controlled with StyleRule yet)

Actual Result

It looks like, if you load a Place or anything like that, if the Instance wasn’t freshly created, StyleRule won’t overwrite the defined properties, in this case it doesn’t overwrite BackgroundColor3.

3 Likes

Thanks for the report! I filed a ticket in our internal database and we’ll follow up when we have an update for you.

1 Like

I need to clarify something because I realized an issue here in my Bug Report, which makes it unclear.

In the Test Game

Step 2 Currently says to overwrite the BackgroundColor3 property manually. This alone sounds like intended behavior.

Instead of running Step 2, save the game CTRL + S, and re-open it, after executing Step 1.

The bug, is that when you save the game. It will also save that what the StyleRules are modifying, and then it won’t modify them anymore.

 

Otherwise, overwriting properties, seems intended, due to.

FFlagEnableModifiedPropertyLuaApis

Which enables IsPropertyModified and ResetPropertyToDefault

When you manually change a property, that property becomes modified. And maybe it’s intended that StyleSheets stops updating overwritten content. Sorta like Inline StyleRules in HTML and CSS

ResetPropertyToDefault then effectively, resets it and StyleRules will modify the values again.

If you run

game:GetService("StarterGui").ScreenGui.TextLabel:ResetPropertyToDefault("BackgroundColor3")

It will erase the modified property.

 

 

Initially I wanted to make reproduction steps for what happens when you save a game with Frames.
The actual issue that I am trying to mention here is that, when you create a Frame and save the game, regardless if IsPropertyModified is true or false, it will save the BackgroundColor3 onto the file. Even though the Property is not modified.

So, we could say that this Bug Report can be changed to:

Saving game writes the Property modifications applied by Style Rules, onto the Properties of the target Instance, disabling the effects of Style Rules on that Instance, when re-opening the game

Description

When saving a game, non-modified properties that are being modified by Style Rules, get saved as well, causing the StyleSheet not to apply StyleRules, because IsPropertyModified then becomes true, when re-opening the file

The bug, is that when you save the game. It will also save that what the StyleRules are currently applying, and then it won’t modify them anymore.

 

Reproduction Steps:

  1. Get the game from above.
  2. Run the scripts inside the game, except Step 2. Instead of copy pasting Step 2 into the console, save the game CTRL + S, and re-open it.
  3. Then you may run Step 3.

Don’t forget FFlagEnableStylingEverywhere is required to be set to true.

Scripts are inside StarterGui
image

 

Expected Result

Style Rules, apply colors. But when I save the game, it should still leave all Properties alone. Now… the Engine could ignore everything where IsPropertyModified is false.

BUT if Roblox ever changes the default Background color, of a Frame. Games would have their background color changed too, if that change would get made.

Checking if the Property was modified by a Style Rule, and then ignore that when saving a game, maybe would work. But, things like Instance.new("Frame", game.Workspace) don’t seem to apply when you save, so it shouldn’t break anything. So it shouldn’t matter.

 

Actual Result

Style Rules, apply colors.

When I save the game after Style Rules have done that, everything that the Style Rules applied, will then also get applied onto the Properties. So the next time I re-open the game file, changes made to Style Rules, won’t apply onto the Frames.

 

I can not change the title of this Bug Report, as this was through Bug-Support.

1 Like