fix: generic UNSET_SENTINEL for child-device override with "none/default" values#16
fix: generic UNSET_SENTINEL for child-device override with "none/default" values#16Copilot wants to merge 2 commits into
Conversation
…alues for alignment and font-size Agent-Logs-Url: https://github.com/maxpertici/responsive-settings/sessions/878f9e24-6651-4e51-a7cb-c95586d84010 Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com>
… for clarity Agent-Logs-Url: https://github.com/maxpertici/responsive-settings/sessions/878f9e24-6651-4e51-a7cb-c95586d84010 Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com>
|
@copilot T es sur de l approche ? J'ai pas besoin de reset le css, je parle des valeurs des styles gut par defaut |
Oui, les deux parties (JS + CSS) sont nécessaires pour des raisons différentes : Pourquoi le sentinel JS ? Pourquoi le CSS ? [data-rwp-id="x"] { max-width: var(--wp--style--global--wide-size) !important; }Sans CSS mobile, ce Pourquoi
C'est bien la "valeur par défaut des styles Gutenberg" dans tous les cas — Si tu as un scénario où le résultat n'est pas le bon, partage-le et j'ajusterai. |
On tablet/mobile, selecting "none" for alignment or "default" for font-size stored a deletion (
null) in the responsive store, causing the property to disappear and inherit the parent device's value instead of being explicitly overridden.Root cause
nullis the deepMerge deletion sentinel — storing it on a child device removes the key, making the override invisible.Approach:
UNSET_SENTINEL = '__rwp_unset__'A string sentinel that survives JSON round-trips and signals "explicitly none on this device."
JS —
intercept-set-attributes.jssplitAttributeUpdatesnow receivescurrentDeviceand passes it downUNSET_SENTINELinstead ofnull:undefinedreset (setAttributes({ textAlign: undefined }))source === '')collectRemovedResponsivePathsForObjectUpdate)null/ deletion)JS —
apply-responsive-settings.jsbuildNativeAttributeUpdates: skips sentinel values — doesn't write'__rwp_unset__'as a native block attributebuildNativeAttributeUpdatesForDevice: treatseffectiveValue === UNSET_SENTINELas absent, so the removal loop fires and properly unsets the attribute (undefinedfor flat props,deleteNestedValuefor nested)PHP —
responsive-settings.phpRESPONSIVE_SETTINGS_UNSET_SENTINEL = '__rwp_unset__'globally before autoloadPHP — all
settings/*/css.phpEach generator now detects the sentinel and emits
property: unset !important, which beats any parent-device!importantrule:Sentinel passes through
SettingsValidator::sanitizePropertyValueunchanged (sanitize_text_field('__rwp_unset__') === '__rwp_unset__').