Skip to content

Commit

Permalink
code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-stoian-lgp committed Dec 19, 2024
1 parent a788ad0 commit 2d47f7a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Slider/SliderBehaviorDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultConfig = {
emitSpotlightEvents: null
};

const sliderDefaultProps = {
const sliderBehaviorDefaultProps = {
max: 100,
min: 0,
orientation: 'horizontal'
Expand All @@ -40,8 +40,9 @@ const sliderDefaultProps = {
const SliderBehaviorDecorator = hoc(defaultConfig, (config, Wrapped) => {
const {emitSpotlightEvents} = config;

const SliderBehavior = (props) => {
const sliderBehaviorProps = setDefaultProps(props, sliderDefaultProps);
// eslint-disable-next-line no-shadow
const SliderBehaviorDecorator = (props) => {
const sliderBehaviorProps = setDefaultProps(props, sliderBehaviorDefaultProps);

const paused = useMemo(() => new Pause(), []);
const [active, setActive] = useState(false);
Expand Down Expand Up @@ -81,31 +82,31 @@ const SliderBehaviorDecorator = hoc(defaultConfig, (config, Wrapped) => {
const handleActivate = useCallback(() => {
forwardCustom('onActivate')(null, sliderBehaviorProps);
setActive(prevState => !prevState);
}, [setActive, sliderBehaviorProps]);
}, [sliderBehaviorProps]);

const handleBlur = useCallback((ev) => {
forward('onBlur', ev, sliderBehaviorProps);
setFocused(false);
setUseHintText(true);
}, [setFocused, setUseHintText, sliderBehaviorProps]);
}, [sliderBehaviorProps]);

const handleDragStart = useCallback(() => {
paused.pause();
setDragging(true);
}, [paused, setDragging]);
}, [paused]);

const handleDragEnd = useCallback(() => {
paused.resume();
setDragging(false);
}, [paused, setDragging]);
}, [paused]);

const handleFocus = useCallback((ev) => {
forward('onFocus', ev, sliderBehaviorProps);
if (!sliderBehaviorProps.activateOnSelect) {
handleActivate();
}
setFocused(true);
}, [handleActivate, setFocused, sliderBehaviorProps]);
}, [handleActivate, sliderBehaviorProps]);

const handleSpotlightEvents = useCallback((ev) => {
if (!emitSpotlightEvents) {
Expand Down Expand Up @@ -144,9 +145,9 @@ const SliderBehaviorDecorator = hoc(defaultConfig, (config, Wrapped) => {
);
};

SliderBehavior.displayName = 'SliderBehaviorDecorator';
SliderBehaviorDecorator.displayName = 'SliderBehaviorDecorator';

SliderBehavior.propTypes = {
SliderBehaviorDecorator.propTypes = {
activateOnSelect: PropTypes.bool,
'aria-valuetext': PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
max: PropTypes.number,
Expand All @@ -155,7 +156,7 @@ const SliderBehaviorDecorator = hoc(defaultConfig, (config, Wrapped) => {
value: PropTypes.number
};

return SliderBehavior;
return SliderBehaviorDecorator;
});

export default SliderBehaviorDecorator;
Expand Down

0 comments on commit 2d47f7a

Please sign in to comment.