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: onRenderChange callback trigger on resize #2228

Merged
merged 9 commits into from
Nov 7, 2023
Merged

Conversation

nickofthyme
Copy link
Collaborator

@nickofthyme nickofthyme commented Nov 2, 2023

Summary

The onRenderChange was not being fired on resize of the chart even though the resize caused the chart to re-render. Adds an onWillRender and onResize events to the Settings spec.

This also reworks the resizeDebounce logic to update the debounce time when changed and remove the debouncer completely when resizeDebounce is set to 0.

Details

The ChartResizer triggers the update of the parent dimensions in the redux state but for some reason this does not affect the state.chartId, state.chartRendered, state.chartRenderedCount, nor getDebugStateSelector(state), the ChartStatus component never updates, and thus never triggers the onRenderChange callback event.

Issues

fixes #2221

Checklist

  • The proper chart type label has been added (e.g. :xy, :partition)
  • The proper feature labels have been added (e.g. :interactions, :axis)
  • All related issues have been linked (i.e. closes #123, fixes #123)
  • Unit tests have been added or updated to match the most common scenarios

@nickofthyme nickofthyme added bug Something isn't working :chart Chart element related issue :xy Bar/Line/Area chart related :all Applies to all chart types labels Nov 2, 2023
@nickofthyme
Copy link
Collaborator Author

buildkite update screenshots

}

type ResizerProps = ResizerStateProps & ResizerDispatchProps;

const DEFAULT_RESIZE_DEBOUNCE = 200;
Copy link
Collaborator Author

@nickofthyme nickofthyme Nov 7, 2023

Choose a reason for hiding this comment

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

This was never used cuz Settings has its own default of 10.

Comment on lines +59 to +61
componentDidUpdate({ resizeDebounce }: Readonly<ResizerProps>): void {
if (resizeDebounce !== this.props.resizeDebounce) this.setupResizeDebounce();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If resizeDebounce value was changed after the initial chart render, the value and thus this.onResizeDebounce was never updated. This adds an update to this.onResizeDebounce on componentDidUpdate.

Even setting the value directly on the settings with a storybook knob was too async to update the value and thus never using the initial knob value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could consider removing this deboucer altogether as it was an original implementation that may not be needed or at the very least default to 0 (aka disabled).

@nickofthyme nickofthyme merged commit be30c1b into main Nov 7, 2023
13 checks passed
@nickofthyme nickofthyme deleted the will-render-v2 branch November 7, 2023 15:29
nickofthyme pushed a commit that referenced this pull request Nov 8, 2023
# [61.0.0](v60.0.0...v61.0.0) (2023-11-08)

### Bug Fixes

* `onRenderChange` callback trigger on resize ([#2228](#2228)) ([be30c1b](be30c1b))
* **axis:** always render `tickLine` unless `visible` is `false` ([#2194](#2194)) ([ec95d50](ec95d50))
* **BarSeries:** ignore histogram mode in determining stacked series ([#2225](#2225)) ([27b4281](27b4281))
* clamp brushing min of last bucket ([#2227](#2227)) ([155c22d](155c22d))
* **deps:** update dependency @elastic/eui to ^88.5.0 ([#2179](#2179)) ([2bb921e](2bb921e))
* **deps:** update dependency @elastic/eui to ^88.5.4 ([#2190](#2190)) ([05b33e5](05b33e5))
* **deps:** update dependency @elastic/eui to ^89.1.0 ([#2212](#2212)) ([a91f68d](a91f68d))
* **deps:** update dependency @elastic/eui to v89 ([#2193](#2193)) ([132327d](132327d))
* **deps:** update dependency @elastic/eui to v90 ([#2222](#2222)) ([10cd53b](10cd53b))

### chore

* reclaim charts theme ownership from eui ([#2175](#2175)) ([422c7d5](422c7d5))

### Features

* **metric:** allow alpha colors and improve contrast logic  ([#2184](#2184)) ([dd5732e](dd5732e))

### BREAKING CHANGES

* **BarSeries:** now ignores histogram mode in determining stacked series
* elastic charts theme renamed to `LEGACY_DARK_THEME` and `LEGACY_LIGHT_THEME` in favor of the main `DARK_THEME` and `LIGHT_THEME` which was merged with eui theme overrides. These new themes are now default.
* **axis:** Now respects `tickLine.padding` whenever `tickLine.visible` is `true`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:all Applies to all chart types bug Something isn't working :chart Chart element related issue :xy Bar/Line/Area chart related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onRenderChange not called on chart resize
1 participant