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

[EuiRange][EuiDualRange] Respond to resizing/layout changes #7442

Merged
merged 6 commits into from
Jan 3, 2024

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Jan 3, 2024

Summary

closes #6846

This PR adds a resize observer to both EuiRange and EuiDualRange components, instead of only obtaining the trackWidth/rangeWidth on ref mount. TBH, I probably should have taken this approach in #7305 in the first place, as it allows us to simplify a good chunk of logic in EuiDualRange

Before After
before_accordion after_accordion
before_fullwidth after_fullwidth

QA

  • Go to https://eui.elastic.co/pr_7442/#/forms/range-sliders
  • Scroll down to the first demo on the page
  • Confirm that the range ticks are correctly positioned on accordion option
  • Scroll down to the last demo on the page (kitchen sink)
  • Click the Display toggles buttons and toggle both to fullWidth
  • Confirm that both range ticks, highlights, and thumbnails update correctly on width change

General checklist

  • Revert [REVERT ME] commit
  • Browser QA
    • Checked in Chrome, Safari, Edge, and Firefox
      - [ ] Checked in both light and dark modes
      - [ ] Checked in mobile
      - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA - N/A, bugfix
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
      - [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist - N/A

+ update parent range components to use the `onResize` callback instead of a ref callback
- the internal resize observer handles all of it, no need for all this extra shenanigans

- probably should've taken this approach in the first place

- remove `onResize` class ref - should no longer be needed in Kibana
- Honestly not sure how useful this is, but better to have something than nothing

- we should eventually replace with with visual snapshot tests
@cee-chen cee-chen changed the title [EuiRange][EuiDualRange] Respond to layout changes/ [EuiRange][EuiDualRange] Respond to resizing/layout changes Jan 3, 2024
@cee-chen cee-chen marked this pull request as ready for review January 3, 2024 01:22
@cee-chen cee-chen requested a review from a team as a code owner January 3, 2024 01:22
// Whether we like it or not, at least 2 Kibana instances are using EuiDualRange
// `ref`s to access the `onResize` instance method (search for `rangeRef.current?.onResize`)
// If we switch EuiDualRange to a function component, we'll need to use `useImperativeHandle`
// to allow Kibana to continue calling `onResize`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I double checked this usage in Kibana, and there's just 1 left, and it should be completely removable now that we've added our own resize observer

}
/>
</>
{isDraggable && this.isValid && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is primarily just indentation changes - I recommend viewing the diff with whitespace changes turned off

};

// TODO: These should likely be visual snapshot regression tests instead
const assertRangePositions = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't love these tests and personally think they're pretty tedious/fragile and not much better than snapshots, but they'll hopefully at least help us catch any weird positioning regressions like #7304. IMO, ideally we'd replace them with visual regression tests instead

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

👍 LGTM! I tested the QA parameters in the four evergreen browsers and tested on Chorme using the mobile preview and scrolled it to different widths to see how it'd react.

@cee-chen
Copy link
Contributor Author

cee-chen commented Jan 3, 2024

Woohoo! Thanks Trevor!

@cee-chen cee-chen enabled auto-merge (squash) January 3, 2024 18:50
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@cee-chen cee-chen merged commit 971fea2 into elastic:main Jan 3, 2024
7 checks passed
@cee-chen cee-chen deleted the range-resize-fix branch January 3, 2024 19:12
cee-chen added a commit to elastic/kibana that referenced this pull request Jan 10, 2024
`v91.3.1`⏩`v92.0.0-backport.0`

---

##
[`v92.0.0-backport.0`](https://github.com/elastic/eui/releases/v92.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

**Bug fixes**

- Fixed an `EuiTreeView` JSX Typescript error
([#7452](elastic/eui#7452))
- Fixed a color console warning being generated by disabled `EuiStep`s
([#7454](elastic/eui#7454))


## [`v92.0.0`](https://github.com/elastic/eui/releases/v92.0.0)

- Updated generic types of `EuiBasicTable`, `EuiInMemoryTable` and
`EuiSearchBar.Query.execute` to add `extends object` constraint
([#7340](elastic/eui#7340))
- This change should have no impact on your applications since the
updated types only affect properties that exclusively accept object
values.
- Added a new `EuiFlyoutResizable` component
([#7439](elastic/eui#7439))
- Updated `EuiTextArea` to accept `isClearable` and `icon` as props
([#7449](elastic/eui#7449))

**Bug fixes**

- `EuiRange`/`EuiDualRange`'s track ticks & highlights now update their
positions on resize ([#7442](elastic/eui#7442))

**Deprecations**

- Updated `EuiFilterButton` to remove the second
`.euiFilterButton__textShift` span wrapper. Target
`.euiFilterButton__text` instead
([#7444](elastic/eui#7444))

**Breaking changes**

- Removed deprecated `EuiNotificationEvent`. We recommend copying the
component to your application if necessary
([#7434](elastic/eui#7434))
- Removed deprecated `EuiControlBar`. We recommend using `EuiBottomBar`
instead ([#7435](elastic/eui#7435))
delanni pushed a commit to delanni/kibana that referenced this pull request Jan 11, 2024
`v91.3.1`⏩`v92.0.0-backport.0`

---

##
[`v92.0.0-backport.0`](https://github.com/elastic/eui/releases/v92.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

**Bug fixes**

- Fixed an `EuiTreeView` JSX Typescript error
([elastic#7452](elastic/eui#7452))
- Fixed a color console warning being generated by disabled `EuiStep`s
([elastic#7454](elastic/eui#7454))


## [`v92.0.0`](https://github.com/elastic/eui/releases/v92.0.0)

- Updated generic types of `EuiBasicTable`, `EuiInMemoryTable` and
`EuiSearchBar.Query.execute` to add `extends object` constraint
([elastic#7340](elastic/eui#7340))
- This change should have no impact on your applications since the
updated types only affect properties that exclusively accept object
values.
- Added a new `EuiFlyoutResizable` component
([elastic#7439](elastic/eui#7439))
- Updated `EuiTextArea` to accept `isClearable` and `icon` as props
([elastic#7449](elastic/eui#7449))

**Bug fixes**

- `EuiRange`/`EuiDualRange`'s track ticks & highlights now update their
positions on resize ([elastic#7442](elastic/eui#7442))

**Deprecations**

- Updated `EuiFilterButton` to remove the second
`.euiFilterButton__textShift` span wrapper. Target
`.euiFilterButton__text` instead
([elastic#7444](elastic/eui#7444))

**Breaking changes**

- Removed deprecated `EuiNotificationEvent`. We recommend copying the
component to your application if necessary
([elastic#7434](elastic/eui#7434))
- Removed deprecated `EuiControlBar`. We recommend using `EuiBottomBar`
instead ([elastic#7435](elastic/eui#7435))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiRange] trackWidth does not update after mount
4 participants