File tree 4 files changed +52
-7
lines changed
4 files changed +52
-7
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Changed
11
+
12
+ - Prevents ` Slider ` range from resetting when the min/max value changes.
13
+
10
14
## [ 9.146.3] - 2022-09-08
11
15
12
16
### Fix
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ const handleInputChange = event => {
48
48
}
49
49
}
50
50
51
- const handleSubmit = ( e ) => {
51
+ const handleSubmit = e => {
52
52
e .preventDefault ()
53
53
54
54
const { left: leftValueInput , right: rightValueInput } = inputValues
@@ -89,7 +89,11 @@ const handleSubmit = (e) => {
89
89
value= {inputValues .right }
90
90
/ >
91
91
< / div>
92
- < Button type= " submit" onClick= {handleSubmit} variation= " primary" size= " small" >
92
+ < Button
93
+ type= " submit"
94
+ onClick= {handleSubmit}
95
+ variation= " primary"
96
+ size= " small" >
93
97
Submit
94
98
< / Button>
95
99
< / form>
Original file line number Diff line number Diff line change @@ -66,16 +66,16 @@ export default class Slider extends Component {
66
66
componentDidUpdate ( prevProps ) {
67
67
if ( prevProps . min !== this . props . min || prevProps . max !== this . props . max ) {
68
68
this . setState (
69
- {
69
+ prev => ( {
70
70
translate : {
71
71
left : 0 ,
72
72
right : 0 ,
73
73
} ,
74
74
values : {
75
- left : this . props . min ,
76
- right : this . props . max ,
75
+ left : prev . values . left ?? this . props . min ,
76
+ right : prev . values . right ?? this . props . max ,
77
77
} ,
78
- } ,
78
+ } ) ,
79
79
this . updateLayout
80
80
)
81
81
}
Original file line number Diff line number Diff line change @@ -2,10 +2,47 @@ import React from 'react'
2
2
3
3
import PageHeader from '../PageHeader'
4
4
import Layout from '../Layout'
5
+ import Button from '../Button'
6
+ import Slider from '../Slider'
7
+
8
+ const SliderTest = ( ) => {
9
+ const [ max , setMax ] = React . useState ( 10 )
10
+ const defaultValues = [ 2 , 8 ]
11
+
12
+ const handleSubmit = e => {
13
+ e . preventDefault ( )
14
+
15
+ setMax ( value => value + 10 )
16
+ }
17
+
18
+ return (
19
+ < >
20
+ < form className = "flex items-end mb5" >
21
+ < Button
22
+ type = "Increase max value +10"
23
+ onClick = { handleSubmit }
24
+ variation = "primary"
25
+ size = "small" >
26
+ Increase max value +10
27
+ </ Button >
28
+ </ form >
29
+
30
+ < div className = "mt8" >
31
+ < Slider
32
+ min = { 0 }
33
+ max = { max }
34
+ alwaysShowCurrentValue = { false }
35
+ range
36
+ defaultValues = { defaultValues }
37
+ />
38
+ </ div >
39
+ </ >
40
+ )
41
+ }
5
42
6
43
const Playground = ( ) => (
7
44
< Layout fullWidth pageHeader = { < PageHeader title = "Playground" /> } >
8
- { /* Add your code here, don't forget to delete after */ }
45
+ < SliderTest />
9
46
</ Layout >
10
47
)
11
48
You can’t perform that action at this time.
0 commit comments