ScratchAddons / ScratchAddons

All-in-one browser extension for Scratch.
https://scratchaddons.com
GNU General Public License v3.0
698 stars 365 forks source link

Setting `if.settings` should be an AND condition #5692

Open mxmou opened 1 year ago

mxmou commented 1 year ago

The following code can be used to demonstrate the issue:

addon.json:

{
  "name": "Test",
  "description": "Test.",
  "tags": ["community"],
  "dynamicEnable": true,
  "dynamicDisable": true,
  "updateUserstylesOnSettingsChange": true,
  "userstyles": [
    {
      "url": "test.css",
      "matches": ["scratchWWWNoProject"],
      "if": {
        "settings": {
          "checkbox1": true,
          "checkbox2": true
        }
      }
    }
  ],
  "settings": [
    {
      "id": "checkbox1",
      "type": "boolean",
      "name": "Checkbox 1",
      "default": false
    },
    {
      "id": "checkbox2",
      "type": "boolean",
      "name": "Checkbox 2",
      "default": false
    },
    {
      "id": "checkbox3",
      "type": "boolean",
      "name": "Checkbox 3",
      "default": false,
      "if": {
        "settings": {
          "checkbox1": true,
          "checkbox2": true
        }
      }
    }
  ]
}

test.css:

#navigation {
  background-color: orange !important;
}

The condition for the userstyle and the "Checkbox 3" setting is identical, but they behave differently:

_Originally posted by @mxmou in https://github.com/ScratchAddons/ScratchAddons/pull/5546#discussion_r1095556607_

DNin01 commented 1 year ago

This behavior is also inconsistent with the documentation:

In the following example, the signature setting must equal true and the mode setting must equal forums in order for this setting to be visible.

The docs state that it is a logical AND, but it actually functions as a logical OR, AFAIK.