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: calculated height displayed in the inspector for Button and Tile #403

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: calculated height displayed in the inspector for Button and Tile
erautenberg committed Nov 9, 2023
commit 2a71630360a302311b1e2f3a0fb48b9cbfacc807
Original file line number Diff line number Diff line change
@@ -241,14 +241,6 @@ export default class Button extends Surface {
this._Content.patch(this._contentProps);
}

set h(v) {
super.h = v;
}

get h() {
return super.h || this.style.textStyle.lineHeight + this.style.paddingY * 2;
}

_updateSurfaceDimensions() {
let newWidth = this.w;
if (this.fixed) {
@@ -269,7 +261,15 @@ export default class Button extends Surface {
this.w = newWidth;
}

// TODO breaks row resizing if this is wrapped in the above conditional
// In order to ensure the "hSetByUser" flag is not set to true,
// skip over "set h" by directly updating "_h"
// Using the "get h" return statement does not force an update to the inspector,
// whereas this will ensure the "height" attribute is updated
if (!this._hSetByUser && !this.style.h) {
this._h = this.style.textStyle.lineHeight + this.style.paddingY * 2;
}

// TODO breaks row resizing if this is wrapped in the width conditional above
this.fireAncestors('$itemChanged');
}

18 changes: 11 additions & 7 deletions packages/@lightningjs/ui-components/src/components/Tile/Tile.js
Original file line number Diff line number Diff line change
@@ -130,14 +130,13 @@ export default class Tile extends Surface {

/* ------------------------------ Tile ------------------------------ */

set h(v) {
super.h = v;
}

get h() {
_getRenderHeight() {
// if there is Metadata below the Tile, override _getRenderHeight
// in order to return the fully calculated height,
// not the height stored in "_h" for just the tile image
return !this._isInsetMetadata
? super.h + ((this._Metadata && this._Metadata.h) || 0)
: super.h;
? this._h + (this._Metadata?.h + this.style.paddingY || 0)
: super._getRenderHeight();
}

get innerH() {
@@ -624,6 +623,11 @@ export default class Tile extends Surface {
_metadataLoaded() {
this._animateMetadata();
this._updateLogo();

// if the metadata height has changed, the height of the entire Tile has changed
// and the inspector must be updated via _getRenderHeight()
this._updateDimensions();

// Send event to columns/rows that the height has been updated since metadata will be displayed below the Tile
if (!this._isInsetMetadata) {
this.fireAncestors('$itemChanged');
Original file line number Diff line number Diff line change
@@ -337,7 +337,7 @@ export default function withThemeStyles(Base, mixinStyle = {}) {
* @return {number}
*/
get h() {
return (this._hSetByUser && this._h) || this.style?.h || 0;
return (this._hSetByUser && this._h) || this.style?.h || this._h || 0;
}

/**