Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into andreasn/remove-form
Browse files Browse the repository at this point in the history
  • Loading branch information
rinrub committed Jan 29, 2024
2 parents 15ebb08 + 51b8891 commit 837b3d2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 14.0.1

---

- fixed slidercomponent not showing children

## 14.0.0-beta02

- Added table feature to new major version
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helsenorge/refero",
"version": "14.0.0-beta02",
"version": "14.0.1",
"engines": {
"node": "^18.0.0",
"npm": ">=9.0.0"
Expand Down
6 changes: 5 additions & 1 deletion src/components/formcomponents/choice/choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ const Choice: React.FC<ChoiceProps & ValidationProps> = props => {
};

const renderSlider = (): JSX.Element => {
return <SliderView item={props.item} handleChange={handleChange} />;
return (
<SliderView item={props.item} handleChange={handleChange}>
{props.children}
</SliderView>
);
};

const renderAutosuggest = (): JSX.Element => {
Expand Down
12 changes: 10 additions & 2 deletions src/components/formcomponents/choice/slider-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { getExtension } from '../../../util/extension';
interface SliderProps {
item: QuestionnaireItem;
handleChange: (sliderStep: string) => void;
children: React.ReactNode;
}

type LeftRightLabels = [leftLabel: string, rightLabel: string];

const SliderView: React.FC<SliderProps> = ({ item, handleChange }) => {
const SliderView: React.FC<SliderProps> = ({ item, handleChange, children }) => {
const title = item.text;
const [sliderSteps, setSliderSteps] = React.useState<SliderStep[] | undefined>(undefined);
const [leftRightLabels, setleftRightLabels] = React.useState<LeftRightLabels | undefined>(undefined);
Expand All @@ -36,7 +37,14 @@ const SliderView: React.FC<SliderProps> = ({ item, handleChange }) => {

return (
<div className="page_refero__component page_refero__component_choice page_refero__component_choice_slider">
<Slider title={title} labelLeft={leftRightLabels?.[0]} labelRight={leftRightLabels?.[1]} onChange={onValueChange} steps={sliderSteps} />
<Slider
title={title}
labelLeft={leftRightLabels?.[0]}
labelRight={leftRightLabels?.[1]}
onChange={onValueChange}
steps={sliderSteps}
/>
{children ? <div className="nested-fieldset nested-fieldset--full-height">{children}</div> : undefined}
</div>
);
};
Expand Down
7 changes: 6 additions & 1 deletion src/components/formcomponents/open-choice/open-choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,13 @@ const OpenChoice: React.FC<OpenChoiceProps & ValidationProps> = props => {
</AutosuggestView>
);
};

const renderSlider = (): JSX.Element => {
return <SliderView item={props.item} handleChange={handleChange} />;
return (
<SliderView item={props.item} handleChange={handleChange}>
{props.children}
</SliderView>
);
};
// React.useMemo(() => {
// const responseItemHasChanged = props.responseItem !== props.responseItem;
Expand Down

0 comments on commit 837b3d2

Please sign in to comment.