Skip to content

Commit

Permalink
Fix display bug for path for new tobira page
Browse files Browse the repository at this point in the history
The display for the path for a new tobira page
was always one character behind what the user
entered. This fixes that.
  • Loading branch information
Arnei committed Jun 20, 2024
1 parent 7ceea37 commit ab34f2c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/events/partials/ModalTabsAndPages/NewTobiraPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ const NewTobiraPage = <T extends RequiredFormProps>({
}
}

const updatePath = (page: TobiraPage) => {
const updatePath = (page: TobiraPage, lastSegment: string) => {
return formik.values.breadcrumbs
.concat(page).map(function (page) {
return page.segment;
})
.join('/');
.join('/')
.replace(/([^\/]+$)/, lastSegment);
}

const goto = (page: TobiraPage) => {
Expand Down Expand Up @@ -292,23 +293,27 @@ const NewTobiraPage = <T extends RequiredFormProps>({
placeholder={t('EVENTS.SERIES.NEW.TOBIRA.PATH_SEGMENT')}
value={page.segment}
onChange={(e) => {
dispatch(setTobiraPage({
const payload = {
...currentPage,
children: currentPage.children.map((p, k) => {
if (k === key) {
let newPage = {
...p,
path: updatePath(p),
path: updatePath(p, e.target.value),
segment: e.target.value
}

console.log(newPage.path)
console.log(e.target.value)

formik.setFieldValue("selectedPage", newPage)

return newPage;
}
return {...p};
})
}))
}
dispatch(setTobiraPage(payload))
}}
></input>
) : (
Expand Down

0 comments on commit ab34f2c

Please sign in to comment.