[go: nahoru, domu]

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

fix: zelos full block fields rendering badly #7490

Merged
merged 8 commits into from
Sep 14, 2023

Conversation

BeksOmega
Copy link
Collaborator

The basics

The details

Resolves

Fixes #7442

Proposed Changes

Makes it so that input fields (and subclasses) and colour fields properly switch back and forth between full block fields and normal fields when their blocks are modified.

Reason for Changes

Before they didn't have the ability to switch, so mutated blocks would break.

Test Coverage

Manually tested the following behaviors using the browser console for number inputs and colour fields:

  1. Instantiate a full block field.
  2. Add a label field to it via the console.
  3. Observe how the original field is rerendered to not be a full block field.
  4. Remove the added label field via the console.
  5. Observe how the original field is rerendered to be a full block field again.

I think this would be a good candidate for screen shot testing. The code is so jank and I don't think unit testing is worthwhile.

Documentation

N/A

Additional Information

I disagree with most of how full block fields were implemented, so I've added inline docs discouraging people from using these parts of the API. But they should now approximately work under most circumstances.

Also need to update the colour field in samples, working on that now.

@BeksOmega BeksOmega requested a review from a team as a code owner September 14, 2023 20:23
@github-actions github-actions bot added the PR: fix Fixes a bug label Sep 14, 2023
@BeksOmega BeksOmega marked this pull request as draft September 14, 2023 20:41
@BeksOmega
Copy link
Collaborator Author

Broke something with colour fields, will reopen in a sec.

@BeksOmega BeksOmega marked this pull request as ready for review September 14, 2023 20:47
@@ -797,7 +809,7 @@ export abstract class Field<T = any>
const xOffset =
margin !== undefined
? margin
: this.borderRect_
: !this.isFullBlockField()
? this.getConstants()!.FIELD_BORDER_RECT_X_PADDING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no action required, but i wish the formatter would scooch these lines over because this stacked ternary operator makes me sad :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the question is: do you want your stacked ternary formatted as if it is:

if (cond1) {
  consequent1;
 } else if (cond2) {
  consequent2;
} else {
  consequent3;
}

or as if it is:

if (cond1) {
  consequent1;
 } else
  if (cond2) {
    consequent2;
  } else {
    consequent3;
  }

I would not say the latter style is particularly popular.

core/field_colour.ts Show resolved Hide resolved
core/field_colour.ts Outdated Show resolved Hide resolved
core/field_colour.ts Show resolved Hide resolved
core/field_input.ts Show resolved Hide resolved
core/block.ts Outdated
let nFields = 0;
for (const input of this.inputList) {
if (input.connection) return false;
// TODO: This comment is innacurate. Not sure what we want the spec to be.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just fix the comment. i assume by "text" it means "label" but it doesn't actually make sense to exclude those? like the full block rendering wouldn't make sense if there was a label. so i'd just update the comment.

core/field_colour.ts Show resolved Hide resolved
@BeksOmega BeksOmega enabled auto-merge (squash) September 14, 2023 22:20
@BeksOmega BeksOmega merged commit 25d15fd into google:develop Sep 14, 2023
7 checks passed
@BeksOmega BeksOmega deleted the fix/zelos-full-block-fields branch May 14, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zelos renders wrongly when dynamically adding fields
3 participants