Skip to content

fix(Slider): update slider to respect min/max constraints#6232

Merged
tlabaj merged 1 commit intopatternfly:mainfrom
evwilkin:fix/5893-slider-constraints
Aug 31, 2021
Merged

fix(Slider): update slider to respect min/max constraints#6232
tlabaj merged 1 commit intopatternfly:mainfrom
evwilkin:fix/5893-slider-constraints

Conversation

@evwilkin
Copy link
Member

@evwilkin evwilkin commented Aug 26, 2021

Closes #5893
Closes #5707

Additional issues: Related issue #5833

This PR fixes the issue of being able to enter a value outside slider's min/max via the text input, by passing setLocalInputValue to the user through onChange.
Steps to recreate issue:

  • Set a slider either to max value, or above-max value using the text input.
  • value and inputValue are correctly set to the max value, component state updates & internally updates localInputValue variable which controls the value displayed in the text input.
  • Immediately enter another value above the max, value and inputValue remain at the max value so setState has no effect and the localInputValue is not updated causing above-max value to remain.

This PR also fixes the issue of tabbing through the first two "Value input" examples causes the text input to change to 0, and tabbing through a second time causes the slider to reflect this 0 value, by adding missing newInputValue assignment in example code.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Aug 26, 2021

PF4 preview: https://patternfly-react-pr-6232.surge.sh

event.preventDefault();
if (onChange) {
onChange(localValue, localInputValue);
onChange(localValue, localInputValue, setLocalInputValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

I never knew you could do this!

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks great!

@tlabaj tlabaj merged commit 11dd20e into patternfly:main Aug 31, 2021
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.12.58
  • @patternfly/react-code-editor@4.3.44
  • @patternfly/react-console@4.11.26
  • @patternfly/react-core@4.152.6
  • @patternfly/react-docs@5.21.20
  • @patternfly/react-inline-edit-extension@4.7.67
  • demo-app-ts@4.118.9
  • @patternfly/react-log-viewer@4.5.6
  • @patternfly/react-table@4.29.60
  • @patternfly/react-topology@4.9.64
  • @patternfly/react-virtualized-extension@4.9.33

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants