Skip to content

Commit

Permalink
[controls] fix Time Slider text is not working properly with Dark Mode (
Browse files Browse the repository at this point in the history
#145612)

Fixes #145594

TimeSlider component is not wrapped by KibanaThemeProvider and therefore
does not properly use kibana themeing. This PR resolves the issues by
wrapping TimeSlider by KibanaThemeProvider.

To test
* set advanced setting `theme:darkMode` to true
* open dashboard
* add time slider
* verify timeslider is using dark theme

<img width="500" alt="Screen Shot 2022-11-17 at 12 04 40 PM"
src="https://user-images.githubusercontent.com/373691/202536272-9ef9e9fe-debe-4722-a50e-03929b94c18d.png">

(cherry picked from commit d5ed16a)
  • Loading branch information
nreese committed Nov 17, 2022
1 parent 142a15c commit 3d02967
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import moment from 'moment-timezone';
import { Embeddable, IContainer } from '@kbn/embeddable-plugin/public';
import { ReduxEmbeddableTools, ReduxEmbeddablePackage } from '@kbn/presentation-util-plugin/public';
import type { TimeRange } from '@kbn/es-query';
import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import React from 'react';
import ReactDOM from 'react-dom';
import { Subscription } from 'rxjs';
Expand Down Expand Up @@ -270,16 +271,18 @@ export class TimeSliderControlEmbeddable extends Embeddable<
const { Wrapper: TimeSliderControlReduxWrapper } = this.reduxEmbeddableTools;

ReactDOM.render(
<TimeSliderControlReduxWrapper>
<TimeSlider
formatDate={this.epochToKbnDateFormat}
onChange={(value?: [number, number]) => {
this.onTimesliceChange(value);
const range = value ? value[TO_INDEX] - value[FROM_INDEX] : undefined;
this.onRangeChange(range);
}}
/>
</TimeSliderControlReduxWrapper>,
<KibanaThemeProvider theme$={pluginServices.getServices().theme.theme$}>
<TimeSliderControlReduxWrapper>
<TimeSlider
formatDate={this.epochToKbnDateFormat}
onChange={(value?: [number, number]) => {
this.onTimesliceChange(value);
const range = value ? value[TO_INDEX] - value[FROM_INDEX] : undefined;
this.onRangeChange(range);
}}
/>
</TimeSliderControlReduxWrapper>
</KibanaThemeProvider>,
node
);
};
Expand Down

0 comments on commit 3d02967

Please sign in to comment.