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(dashboard): Prevent char overflow when displaying chart description #14467
fix(dashboard): Prevent char overflow when displaying chart description #14467
Conversation
Codecov Report
@@ Coverage Diff @@
## master #14467 +/- ##
==========================================
- Coverage 77.12% 77.12% -0.01%
==========================================
Files 954 953 -1
Lines 48175 48176 +1
Branches 6063 6053 -10
==========================================
Hits 37155 37155
- Misses 10819 10820 +1
Partials 201 201
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
// fix for https://github.com/apache/superset/issues/12643 | ||
if (prevProps.isExpanded !== this.props.isExpanded) { | ||
this.forceUpdate(); | ||
} |
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.
forceUpdate() is a solution but we should try to avoid all uses of forceUpdate() and only read from this.props and this.state in render().
So i suggest we do this:
- add
descriptionHeight
in component state, initial value = 0 - add
componentDidUpdate
so that we can set descriptionHeight state wheneverisExpanded
prop is changed:
componentDidUpdate(prevProps, prevState, snapshot) {
if (this.props.isExpanded !== prevProps.isExpanded) {
const descriptionHeight =
this.props.isExpanded && this.descriptionRef
? this.descriptionRef.offsetHeight
: 0;
this.setState({
descriptionHeight,
})
}
}
- in
shouldComponentUpdate
, if descriptionHeight state is changed, just like height state is change, should return true:
if (
nextState.width !== this.state.width ||
nextState.height !== this.state.height ||
nextState.descriptionHeight !== this.state.descriptionHeight
) {
return true;
}
- in the end,
getChartHeight()
function should return chart content height by height and descriptionHeight:
getChartHeight() {
const headerHeight = this.getHeaderHeight();
return this.state.height - headerHeight - this.state.descriptionHeight;
}
/testenv up |
@junlincc Ephemeral environment spinning up at http://34.222.14.1:8080. Credentials are |
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.
LGTM
Ephemeral environment shutdown and build artifacts deleted. |
…on (apache#14467) * Force refresh the chart on toggle display description * Use forceUpdate instead of forceRefresh * Instead of forceUpdate, add a state for desciption height Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
…on (apache#14467) * Force refresh the chart on toggle display description * Use forceUpdate instead of forceRefresh * Instead of forceUpdate, add a state for desciption height Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
…on (apache#14467) * Force refresh the chart on toggle display description * Use forceUpdate instead of forceRefresh * Instead of forceUpdate, add a state for desciption height Co-authored-by: Ajay Mancheery <ajaymancheery@Ajays-MacBook-Pro.local>
SUMMARY
Fixes #12643
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
TEST PLAN
CI and manual test
ADDITIONAL INFORMATION