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

Label text inserts extra space afterwards #8699

Open
1 task done
BryanCrotazGivEnergy opened this issue Dec 17, 2024 · 2 comments
Open
1 task done

Label text inserts extra space afterwards #8699

BryanCrotazGivEnergy opened this issue Dec 17, 2024 · 2 comments
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member

Comments

@BryanCrotazGivEnergy
Copy link

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

{
    type: 'hems_desire_set_variable',
    tooltip: '',
    helpUrl: '',
    message0:
      '%1set %2',
    args0: [
      {
        type: 'field_label',
        name: 'thenLabel',
        value: '',
      },
      {
        type: 'field_dropdown',
        name: 'variable',
        options: [
          ['one', '1'],
          ['two', '2'],
          ['three', '3'],
        ],
      }    
    ],
  }

Should render "set [dropdown]"

Actually renders " set [dropdown]"

In code I'm setting the thenLabel to 'then' or '' based on the parent block. When I set it to 'then' it renders then set - note extra space.

Reproduction steps

Stack trace

Screenshots

No response

Browsers

Safari desktop

@BryanCrotazGivEnergy BryanCrotazGivEnergy added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Dec 17, 2024
@gonfunko
Copy link
Contributor

This is largely working as expected; when rendering, Blockly lays out all the text/labels/fields/inputs etc on the row, with spacing between them. The amount of spacing and rules for inserting it can be customized by using a custom renderer and overriding getInRowSpacing_(), but that's quite involved and likely not what you want to do here. Instead, I think if you changed message0 to be %1 %2, and then in your code toggle the thenLabel's text between "then set" and "set", you'd get the behavior you want; there would be two fields, with space between them, and the first would consist of the text while the latter would be the dropdown. At present, even when thenLabel is empty and not itself occupying space, Blockly still notes that a field is there and inserts padding between it and the "set" text; it's that padding that is the cause of the apparent space before "set" or between "then" and "set", so condensing down to just one label field that contains all of the text should sort it out. If that doesn't work for you feel free to reopen!

@BryanCrotaz
Copy link

Reopening.

The bug is that when a field has zero width only one padding should be inserted, not on both sides. If the field is the first one then no padding should be inserted.

In my case I'm applying this to multiple blocks and I don't know what the first word after thenLabel should be.

@gonfunko gonfunko reopened this Dec 19, 2024
@cpcallen cpcallen assigned cpcallen and gonfunko and unassigned cpcallen Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member
Projects
None yet
Development

No branches or pull requests

4 participants