Skip to content

[Controls] Range slider#125584

Merged
cqliu1 merged 12 commits intoelastic:mainfrom
cqliu1:controls/range-slider
Mar 28, 2022
Merged

[Controls] Range slider#125584
cqliu1 merged 12 commits intoelastic:mainfrom
cqliu1:controls/range-slider

Conversation

@cqliu1
Copy link
Copy Markdown
Contributor

@cqliu1 cqliu1 commented Feb 14, 2022

Summary

Related to #120035.

This introduces the range slider control.

Screen Shot 2022-03-21 at 7 13 13 PM

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@cqliu1 cqliu1 added Feature:Input Control Input controls visualization enhancement New value added to drive a business result Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// loe:large Large Level of Effort impact:critical This issue should be addressed immediately due to a critical level of impact on the product. reason:enhancement v8.2.0 labels Feb 14, 2022
@cqliu1 cqliu1 force-pushed the controls/range-slider branch from 1def2b1 to 1e12491 Compare February 23, 2022 20:22
@andreadelrio andreadelrio self-assigned this Mar 2, 2022
@cqliu1 cqliu1 force-pushed the controls/range-slider branch from 4764e2a to 7f45e0e Compare March 15, 2022 15:54
@cqliu1 cqliu1 force-pushed the controls/range-slider branch 3 times, most recently from 6a02826 to 912ea56 Compare March 15, 2022 21:29
@cqliu1 cqliu1 force-pushed the controls/range-slider branch 2 times, most recently from b86da27 to 3c1beff Compare March 17, 2022 00:15
Fix ts error

Fix ref type error

Extracted i18n strings

Fixed number rounding

Fixed missing i18n string

Add loading state to range slider control output

Remove unnecessary change

Fix i18n errors

Apply formatter to range slider tick labels
@cqliu1 cqliu1 force-pushed the controls/range-slider branch from d80ef42 to 9fba1fd Compare March 22, 2022 18:10
@cqliu1 cqliu1 marked this pull request as ready for review March 23, 2022 16:04
@cqliu1 cqliu1 requested review from a team as code owners March 23, 2022 16:04
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

The components look great, and the chaining functionality is working really well! I've left a few nits, mostly around how and when the embeddable fetches data, and how / what it outputs.

One UX issue I discovered is that in cases where a control that comes earlier in the chain uses the same field as the range slider control. In that case, the filter outputted from the range slider overwrites the earlier filter, even though the one that comes earlier should take priority.

This happens because we are outputting the user's selections as filters directly rather than outputting the narrowest range by comparing the selections to the available min max. This is quite an edge case, and could be fixed in a follow-up.

Mar-23-2022 12-42-13


public isEditable = () => Promise.resolve(false);

public getDisplayName = () => 'Range slider';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Should probably use i18n here.

There is also a description that @Heenawter added here for the popover that we can take advantage of!

await this.fetchMinMax();
}
this.setInitializationFinished();
this.setupSubscriptions();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed a small bug here where the minMax is fetched twice on startup. Not exactly sure how to fix it, but I think it's caused here.

distinctUntilChanged((a, b) => isEqual(a.value, b.value)),
skip(1) // skip the first input update because initial filters will be built by initialize.
)
.subscribe(() => this.fetchMinMax())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason you're re-querying the min and max whenever the user makes a selection? This could potentially cause a lot of queries and slow down performance. If it's only in order to publish the filters, I would say maybe those two functions should be split up?

new Error(RangeSliderStrings.errors.getDataViewNotFoundError(dataViewId))
);
}
this.updateOutput({ dataViews: [this.dataView] });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the control group hierarchical chaining system is listening to any output changes Outputting the data views every time you get them could cause lower performance due to the diffing functions having to run more than usual.

I see that you're batching the updateOutput in your getMinMax function, so this line could potentially just be removed?

}

if (timeRange) {
const timeFilter = this.dataService.timefilter.createFilter(dataView, timeRange);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here and below, you're batching the timeFilter and the filterpill filters. Those can be individually turned on and off in #128090. In the code currently, turning off filters would also turn off the time range.

I think it should be pretty straightforward to split those out!

private buildFilter = async () => {
const { value: [selectedMin, selectedMax] = ['', ''] } = this.getInput();

if (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if all of the early returns under here could be combined into one?

cqliu1 and others added 3 commits March 23, 2022 23:39
Copy link
Copy Markdown
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

🎉 Design LGTM with one pending to-do in a follow-up: make the size prop available inside the range slider files. I would like to be able to do some design adjustments for the small size.

@ThomThomson
Copy link
Copy Markdown
Contributor

@andreadelrio, since the size prop is tracked as part of the control frame state, it might not be straightforward to get access to it from inside the range slider components. On top of that, the size prop might not work in all situations, because the auto size can shrink to be the same size as the small size.

All that to say, it might be better to use a trick similar to what we did for the popover size, using an EuiResizeObserver. Then you can change classes or styling based on the actual size of the anchor!

@cqliu1
Copy link
Copy Markdown
Contributor Author

cqliu1 commented Mar 24, 2022

@elasticmachine merge upstream

@cqliu1
Copy link
Copy Markdown
Contributor Author

cqliu1 commented Mar 28, 2022

@elasticmachine merge upstream

Comment on lines +7 to +11
@include euiBreakpoint('m', 'l', 'xl') {
.rangeSlider__panelOverride {
min-width: $euiSizeXXL * 12;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cqliu1 was just using the Cloud environment to run through the questions for the usability testing sessions and I came across this bug. The range popover panel gets cut off when it is on the right side.
image

Removing this media query should solve the issue.

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cqliu1 But we would need to figure out how to handle the small controls after removing that media query
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The quickest suggestion I can think of is to increase the size of the small controls to at least 300px ($euiSizeM * 25). What do you think @ThomThomson ?

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And likely using EuiResizeObserver is a more appropriate fix (like Option List is doing).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this is a reason to use the EuiPopover with EuiResizeObserver rather than using the EuiInputPopover?

I would be hesitant to just increase the size of the small control, as it isn't tied to anything solid. I.e. if the title was set to inline and Average Ticket Price rather than AvgTicketPrice the problem would still happen even with the larger small size.

Either way, I think this should be addressed in a follow-up bugfix PR so that we can get this merged in today for FF!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason why I'm using EuiInputPopover is bc there were focus issues with using the EuiPopover + EuiResizeObserver where you would click on the lower bound number field of the anchor but focus would jump to the range slider in the popover, but if that would solve the popover sizing issues, then it might be worth finding a fix for the focus stuff. I agree with Devon and can address follow up PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

++ on fixing in a follow-up PR.

@cqliu1
Copy link
Copy Markdown
Contributor Author

cqliu1 commented Mar 28, 2022

@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Tested this locally again, and all the behaviours including the hierarchical chaining system are looking great!

I opened two issues while reviewing this: One is an enhancement to the validation system for the range slider.

The other is unrelated to this PR, and is something that I will fix.

Everything LGTM!

@cqliu1 cqliu1 enabled auto-merge (squash) March 28, 2022 20:23
@cqliu1 cqliu1 merged commit ba6be79 into elastic:main Mar 28, 2022
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
controls 147 163 +16

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
controls 135 177 +42

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
controls 404.4KB 420.7KB +16.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
controls 23.5KB 28.1KB +4.6KB
Unknown metric groups

API count

id before after diff
controls 141 183 +42

async chunk count

id before after diff
controls 5 6 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @andreadelrio

@cqliu1 cqliu1 added the Feature:Dashboard Dashboard related features label Mar 28, 2022
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 29, 2022
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125584 or prevent reminders by adding the backport:skip label.

@ThomThomson ThomThomson added the backport:skip This PR does not require backporting label Mar 30, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 30, 2022
@tylersmalley tylersmalley added ci:cloud-deploy Create or update a Cloud deployment and removed ci:deploy-cloud labels Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:cloud-deploy Create or update a Cloud deployment enhancement New value added to drive a business result Feature:Dashboard Dashboard related features Feature:Input Control Input controls visualization impact:critical This issue should be addressed immediately due to a critical level of impact on the product. loe:large Large Level of Effort release_note:enhancement Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants