Null style properties shouldn't override set properties on applied controls

This PG reproduces the issue.

Comment and uncomment out the line that sets control.style = style; to see the difference. The expected behavior if I haven’t defined the fontSize style property would be for the 10% value to be applied. Instead, and it’s not clear from where, a different value (4%?) is used

HTH!

This is the value stored in the style you apply. Styles are unlike in CSS not overriding only some of the property not manually set, here it is either controlled manually or by the style.

@carolhmj could confirm.

Yep we do a switch on the entire _style object here: Babylon.js/control.ts at 797ca272cecf0429a8a8b0bb83a8c105bca65653 · BabylonJS/Babylon.js · GitHub
But I wouldn’t mind having individual switches per property tbh, that might be a nice thing to have :thinking: @RaananW what do you think?

Math.random() * 10? :wink:

I think it’s a wonderful idea, to inherit from the parent and make the GUI a bit closer to CSS. it will have to be behind a flag (back-compat), but it should be technically possible (getter for the values, check parent if value is not defined).

1 Like