Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent nested block config values from conflicting #42

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

mjauvin
Copy link
Member

@mjauvin mjauvin commented Jan 21, 2025

This prevents configs from child elements to interfere with parent elements configs.

@mjauvin mjauvin requested a review from jaxwilko January 21, 2025 18:46
@mjauvin mjauvin self-assigned this Jan 21, 2025
@LukeTowers
Copy link
Member

@mjauvin can you post an example of the problem code before and after?

@mjauvin
Copy link
Member Author

mjauvin commented Jan 21, 2025

I have this custom block:

name: Bullet List
description: Create an ordered/unordered list with different bullet types
icon: icon-list-ul
tags: ["iet"]

fields:
  label:
    label: Label
    commentAbove: (optional)

  items:
    label: Items
    type: blocks
    style: collapsed
    allow:
      - bullet-list
      - line
      - link
      - paragraph

config:
  use_container:
    type: checkbox
    label: Use container
    default: false

  margin:
    label: Left margin
    type: dropdown
    options:
      ml-0: None
      ml-4: Small
      ml-6: Medium
      ml-9: Large
    default: ml-0;

  listType:
    label: List Type
    type: dropdown
    options:
      ol: Ordered List (ol)
      ul: Unordered List (ul)
    default: ul

  bulletType:
    label: Bullet Type
    type: dropdown
    options:
      list-none: None
      list-circle: Circle
      list-disc: Disc
      list-square: Square
      list-decimal: decimal
      list-lower-alpha: Alpha (lowercase)
      list-lower-greek: Greek (lowercase)
      list-lower-roman: Roman (lowercase)
      list-upper-alpha: Alpha (uppercase)
      list-upper-roman: Roman (uppercase)
    default: list-disc
==
{% if label %}
  <label>{{ label }}</label>
{% endif %}
<section class="bullet-list-block w-full {{ (label or config.use_container) ? 'container px-8 lg:px-12' }} mb-6 lg:mb-12 columns-inherit gap-x-[inherit]">
  <{{ config.listType }} class="{{ config.bulletType }} {{ config.margin }} list-inside">
    {% for item in items %}
      <li>{{ renderBlock(item) }}</li>
    {% endfor %}
  </{{ config.listType }}>
</section>

{% put styles %}
<style>
  section.bullet-list-block :is(p,section) {
    display: inline-block;
    vertical-align: middle;
  }
</style>
{% endput %}

If when creating the blocks I have a bullet-list block within a parent bullet-list block, the bulletType config from the child will conflict with the parent config and the same bulletType value will be used for both the parent and the child (even if they have different values).

@LukeTowers LukeTowers changed the title Move inspector configs within $groupDefinitions array Prevent nested block config values from conflicting Jan 25, 2025
@LukeTowers LukeTowers merged commit 2e746a7 into main Jan 25, 2025
6 checks passed
@LukeTowers LukeTowers deleted the isolated-config branch January 25, 2025 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants