Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Issue 485 - Slider className / external styling regression #486

Merged
merged 17 commits into from
Mar 18, 2019

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Mar 11, 2019

Fixes #485

  • fix vertical styling for both slider and range slider
  • fix loading state attribute for range slider
  • added visual and basic functional test for both sliders
  • added loading state attribute test for both sliders

Marc-André Rivet added 3 commits March 11, 2019 11:30
const {value} = this.state;
return (
<div
id={id}
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
className={className}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apply class name to the wrapper. rc-slider applies very little styles to itself and relevant styles will be ok if applied to the parent (e.g. it doesn't explicitly set the color, font-size, etc.) unlike the dropdown.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of the other cases where we allow className, we also allow style - do we want to do that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This is because the wrapper was added with Loading Components and the wrapped slider did not support the style property. I don't mind adding support for styling here -- but will need to handle the existing #481 style applied on the vertical slider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fwiw, the rangeslider does not support style either.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the main purpose of className is styling, it seems appropriate to add style. But as that's a feature rather than a bugfix, feel free to make an issue and defer for later if you don't want to do it in this PR.

@alexcjohnson
Copy link
Collaborator

Can we 🔒 this with a test?

Does this fix (and #479 too I guess) need to be applied to RangeSlider too?

@Marc-Andre-Rivet
Copy link
Contributor Author

This does not affect the range slider, as for some reason that slider (same 3rd party package) supported data-* props

@alexcjohnson
Copy link
Collaborator

OK, I don't see what data-* has to do with these, but I'd feel better if we had these all in a test rather than just reasoning about it. Perhaps a snapshot with single and range sliders in both orientations and a little styling (via class, or inline if you add it here)

@Marc-Andre-Rivet
Copy link
Contributor Author

data-* lack of support was what caused the slider to be wrapped in the first place for the LC feature.

Yeah, writing some additional tests.

@Marc-Andre-Rivet
Copy link
Contributor Author

Marc-Andre-Rivet commented Mar 11, 2019

So.. digging a little bit more in all directions, turns out the range slider should have been wrapped too. I was assuming it worked here #486 (comment) as the difference sort of assumed that in my mind.. anyway, LC attributes don't work there either. Not sure why the slider was tested/wrapped and not the range slider. This is the only 3rd party element that isn't wrapped, not sure how we came to the conclusion it was behaving correctly with LC..

@@ -245,6 +312,112 @@ def test_vertical_slider(self):
for entry in self.get_log():
raise Exception('browser error logged during test', entry)

def test_loading_range_slider(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For both slider and range slider, make sure that the horizontal / vertical version displays correctly using the previously used styling, that the slider nubs can be clicked without error and that loading state is applied correctly to the DOM element

Marc-André Rivet added 2 commits March 18, 2019 15:20
@@ -237,14 +241,16 @@ def test_loading_slider(self):
[Input('test-div', 'children')]
)
def delayed_value(children):
time.sleep(5)
lock.acquire()
lock.release()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very nice @Marc-Andre-Rivet !

@plotly/dash whenever you are tempted to add a time.sleep in tests, take a moment to think "is there a way to do it without a sleep?" A huge fraction of our test time is simply sleep statements, which are set super long in order to be robust.

A lot of the time we can solve this just by waiting for some condition (an element with the right contents, for example). This one is a bit trickier, we were using a sleep in the server process (where callbacks run) to ensure something had time to be observed in the browser-control process, but this commit shows a fairly simple pattern to do this with a Lock so that the server process stops waiting as soon as the browser has seen what it's looking for.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃
Please make an issue for a slider style prop but doesn't need to be done here #486 (comment)

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit 163c954 into master Mar 18, 2019
@Marc-Andre-Rivet Marc-Andre-Rivet deleted the issue485-slider-external-styling branch March 18, 2019 22:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to 0.39 breaks Slider
2 participants