-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Changes from 4 commits
f81df40
a610595
f2a7122
fa9cc6c
67b4464
a0a6c1e
a6b9f8a
faeb677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,6 +330,18 @@ export abstract class Field<T = any> | |
*/ | ||
initModel() {} | ||
|
||
/** | ||
* Defines whether this field should take up the full block or not. | ||
* | ||
* Be cautious when overriding this function. It may not work as you expect / | ||
* intend because the behavior was kind of hacked in. If you are thinking | ||
* about overriding this function, post on the forum with your intended | ||
* behavior to see if there's another approach. | ||
*/ | ||
protected isFullBlockField(): boolean { | ||
return !this.borderRect_; | ||
} | ||
|
||
/** | ||
* Create a field border rect element. Not to be overridden by subclasses. | ||
* Instead modify the result of the function inside initView, or create a | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :( There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
: 0; | ||
let totalWidth = xOffset * 2; | ||
|
@@ -813,7 +825,7 @@ export abstract class Field<T = any> | |
); | ||
totalWidth += contentWidth; | ||
} | ||
if (this.borderRect_) { | ||
if (!this.isFullBlockField()) { | ||
totalHeight = Math.max(totalHeight, constants!.FIELD_BORDER_RECT_HEIGHT); | ||
} | ||
|
||
|
@@ -922,7 +934,7 @@ export abstract class Field<T = any> | |
throw new UnattachedFieldError(); | ||
} | ||
|
||
if (!this.borderRect_) { | ||
if (this.isFullBlockField()) { | ||
// Browsers are inconsistent in what they return for a bounding box. | ||
// - Webkit / Blink: fill-box / object bounding box | ||
// - Gecko: stroke-box | ||
|
@@ -940,8 +952,8 @@ export abstract class Field<T = any> | |
xy.y -= 0.5 * scale; | ||
} | ||
} else { | ||
const bBox = this.borderRect_.getBoundingClientRect(); | ||
xy = style.getPageOffset(this.borderRect_); | ||
const bBox = this.borderRect_!.getBoundingClientRect(); | ||
xy = style.getPageOffset(this.borderRect_!); | ||
scaledWidth = bBox.width; | ||
scaledHeight = bBox.height; | ||
} | ||
|
There was a problem hiding this comment.
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.