Skip to content

Commit 8c44d84

Browse files
BeksOmegarachel-fenichel
authored andcommitted
fix: color field sizing being incorrect (#7566)
(cherry picked from commit 5151b28)
1 parent 2308da8 commit 8c44d84

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

core/field_colour.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,28 +262,20 @@ export class FieldColour extends Field<string> {
262262
*/
263263
protected updateSize_(margin?: number) {
264264
const constants = this.getConstants();
265-
const xOffset =
266-
margin !== undefined
267-
? margin
268-
: !this.isFullBlockField()
269-
? constants!.FIELD_BORDER_RECT_X_PADDING
270-
: 0;
271-
let totalWidth = xOffset * 2;
272-
let contentWidth = 0;
273-
if (!this.isFullBlockField()) {
274-
contentWidth = constants!.FIELD_COLOUR_DEFAULT_WIDTH;
275-
totalWidth += contentWidth;
276-
}
277-
278-
let totalHeight = constants!.FIELD_TEXT_HEIGHT;
279-
if (!this.isFullBlockField()) {
280-
totalHeight = Math.max(totalHeight, constants!.FIELD_BORDER_RECT_HEIGHT);
265+
let totalWidth;
266+
let totalHeight;
267+
if (this.isFullBlockField()) {
268+
const xOffset = margin ?? 0;
269+
totalWidth = xOffset * 2;
270+
totalHeight = constants!.FIELD_TEXT_HEIGHT;
271+
} else {
272+
totalWidth = constants!.FIELD_COLOUR_DEFAULT_WIDTH;
273+
totalHeight = constants!.FIELD_COLOUR_DEFAULT_HEIGHT;
281274
}
282275

283276
this.size_.height = totalHeight;
284277
this.size_.width = totalWidth;
285278

286-
this.positionTextElement_(xOffset, contentWidth);
287279
this.positionBorderRect_();
288280
}
289281

core/renderers/zelos/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ export class ConstantProvider extends BaseConstantProvider {
217217

218218
this.FIELD_DROPDOWN_SVG_ARROW_PADDING = this.FIELD_BORDER_RECT_X_PADDING;
219219

220-
this.FIELD_COLOUR_DEFAULT_WIDTH = 2 * this.GRID_UNIT;
220+
this.FIELD_COLOUR_DEFAULT_WIDTH = 6 * this.GRID_UNIT;
221221

222-
this.FIELD_COLOUR_DEFAULT_HEIGHT = 4 * this.GRID_UNIT;
222+
this.FIELD_COLOUR_DEFAULT_HEIGHT = 8 * this.GRID_UNIT;
223223

224224
this.FIELD_CHECKBOX_X_OFFSET = 1 * this.GRID_UNIT;
225225

0 commit comments

Comments
 (0)