Issue #3525💬 AnsweredOpened June 9, 2021by anlumo0 reactions

In Style Manager, Allow Requiring the Default Setting

快速解答by artf

Hi @anlumo, did you try to extend float definition with something like this requires: { position: ['static'] }?

Read full answer below ↓

Question

What are you trying to add to GrapesJS?

The CSS property float only makes sense for position: static; elements, which happens to be the default. I only want to display the float radio selector if the position is not set to anything else.

However, if I add require: ['static']; to the property definition, the setting is only shown when I explicitly set the position to static, not when I leave it at the default (which is also static).

Is there an alternative at the latest version?

  • Yes (describe the alternative)
  • No

Is this related to an issue?

  • Yes (Give a link to the issue)
  • No

Answers (3)

artfJuly 5, 2021

Hi @anlumo, did you try to extend float definition with something like this requires: { position: ['static'] }?

anlumoJuly 8, 2021

image

Yes. It seems to work fine after reloading the page, but when you toggle the position it stops working and looks like in the screenshot.

The definition is as follows:

{
    name: "Layout",
    open: false,
    buildProps: ['position', 'top', 'bottom', 'left', 'right', 'float'],
    properties: [
        {
            name: "Position",
            property: 'position',
            type: 'radio',
            list: [
                { value: 'static' },
                { value: 'absolute' },
                { value: 'relative' },
            ],
            defaults: 'static',
        },
        {
            property: 'top',
            type: 'integer',
            units: ['mm', 'in', '%'],
            defaults: 'auto',
            fixedValues: ['auto'],
            requires: { position: ['absolute', 'relative'] },
        },
        {
            property: 'bottom',
            type: 'integer',
            units: ['mm', 'in', '%'],
            defaults: 'auto',
            fixedValues: ['auto'],
            requires: { position: ['absolute', 'relative'] },
        },
        {
            property: 'left',
            type: 'integer',
            units: ['mm', 'in', '%'],
            defaults: 'auto',
            fixedValues: ['auto'],
            requires: { position: ['absolute', 'relative'] },
        },
        {
            property: 'right',
            type: 'integer',
            units: ['mm', 'in', '%'],
            defaults: 'auto',
            fixedValues: ['auto'],
            requires: { position: ['absolute', 'relative'] },
        },
        {
            name: "Float",
            property: 'float',
            type: 'radio',
            list: [
                { value: 'none' },
                { value: 'left' },
                { value: 'right' },
            ],
            requires: { position: ['static'], },
        },
    ],
}
ClaudeCodeMay 17, 2026

Thanks for reporting this, @anlumo.

Great suggestion about FEAT: In Style Manager, Allow Requiring the Default Setting! While this specific feature isn't yet in the core API, there are several ways to achieve similar behavior.

Using the event system:

editor.on('component:update', (component) => {
  // your logic here
});

Alternative approaches:

  • Listen to selector:add for CSS selector changes
  • Use selector:custom for custom rules
  • Tap into the change:* events for fine-grained tracking
  • Build a plugin that extends the editor with this capability

Making it official: If this feature would benefit many users, consider opening a formal Feature Request on the GrapesJS repo with:

  • A detailed use case
  • Code example showing the desired behavior
  • Why this matters for your workflow

The core team is receptive to well-motivated feature requests backed by real use cases.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.