Skip to content

Commit 556fc5e

Browse files
committed
fix(web): DRS issue
1 parent e2f996f commit 556fc5e

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

packages/web/src/components/range/DynamicRangeSlider.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DynamicRangeSlider extends Component {
5959
constructor(props) {
6060
super(props);
6161

62-
const { queryFormat } = props;
62+
const { queryFormat, selectedValue } = props;
6363
if (queryFormat) {
6464
if (!isValidDateRangeQueryFormat(queryFormat)) {
6565
throw new Error('queryFormat is not supported. Try with a valid queryFormat.');
@@ -106,6 +106,15 @@ class DynamicRangeSlider extends Component {
106106
// get range before executing other queries
107107
this.updateRangeQueryOptions(props);
108108
}
109+
if (selectedValue) {
110+
if (Array.isArray(selectedValue)) {
111+
this.state.currentValue = selectedValue;
112+
this.updateQuery(selectedValue, props);
113+
} else {
114+
this.state.currentValue = DynamicRangeSlider.parseValue(selectedValue, props);
115+
this.updateQuery(DynamicRangeSlider.parseValue(selectedValue, props), props);
116+
}
117+
}
109118

110119
const { mode } = this.props;
111120
if (mode !== 'test') {
@@ -126,7 +135,6 @@ class DynamicRangeSlider extends Component {
126135
start: props.selectedValue[0],
127136
end: props.selectedValue[1],
128137
});
129-
130138
if (
131139
selectedValueNumericArray[0] >= range.start
132140
&& selectedValueNumericArray[1] <= range.end
@@ -184,11 +192,6 @@ class DynamicRangeSlider extends Component {
184192
this.updateRange(formatRange(this.props.range, this.props));
185193
// only listen to selectedValue initially, after the
186194
// component has mounted and range is received
187-
if (this.props.selectedValue) {
188-
this.handleChange(this.props.selectedValue);
189-
} else {
190-
this.handleChange();
191-
}
192195
} else if (
193196
this.props.range
194197
&& !isEqual(
@@ -435,14 +438,18 @@ class DynamicRangeSlider extends Component {
435438
{ start, end },
436439
props.queryFormat,
437440
);
438-
// always keep the values within range
439-
// props.range.start / (props.queryFormat !== dateFormats.epoch_second ? 1 : 1000) is required
440-
// since we need to convert the milliseconds value into seconds in case of epoch_second
441-
normalizedValue = [
442-
processedStart < props.range.start ? props.range.start : processedStart,
443-
processedEnd > props.range.end ? props.range.end : processedEnd,
444-
];
445-
if (props.range.start === null) {
441+
if (props.range) {
442+
// always keep the values within range
443+
// props.range.start / (props.queryFormat !== dateFormats.epoch_second ? 1 : 1000) is required
444+
// since we need to convert the milliseconds value into seconds in case of epoch_second
445+
normalizedValue = [
446+
processedStart < props.range.start ? props.range.start : processedStart,
447+
processedEnd > props.range.end ? props.range.end : processedEnd,
448+
];
449+
if (props.range.start === null) {
450+
normalizedValue = [processedStart, processedEnd];
451+
}
452+
} else {
446453
normalizedValue = [processedStart, processedEnd];
447454
}
448455
}

0 commit comments

Comments
 (0)