Skip to content

Commit

Permalink
35522 add group edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
lcbdl committed Jan 16, 2025
1 parent c9ce929 commit 4d878b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dina-ui/components/group/GroupLabelsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ export function GroupLabelsEditor({ valuesPath }: GroupLabelsEditorProps) {
<FormikButton
className="btn remove-attribute"
onClick={(_, form) => {
// Delete the value and hide the managed attribute:
// Delete the value and hide the label:
form.setFieldValue(
`${valuesPath}.${language}`,
undefined
);
// Add the language back to availableLanguages
setAvailableLanguages(
concat(availableLanguages, language).sort()
);
// Remove the language from visibleLanguages
setVisibleLanguages((languages) =>
languages.filter((lang) => lang !== language)
);
Expand All @@ -104,12 +106,15 @@ export function GroupLabelsEditor({ valuesPath }: GroupLabelsEditorProps) {
onChange={(value) => {
const selectedLang = value?.value;
if (selectedLang) {
// add the language to visibleLanguages
setVisibleLanguages(
concat(visibleLanguages, selectedLang)
);
// remove the language from availableLanguages
setAvailableLanguages((languages) =>
languages.filter((lang) => lang !== selectedLang)
);
// set fieldValue in the formik.
form.setFieldValue(`${valuesPath}.${selectedLang}`, "");
}
}}
Expand Down

0 comments on commit 4d878b8

Please sign in to comment.