Skip to content

Commit a89c999

Browse files
committed
Merge branch 'safari-metadata-multiselect-removing-entries' of Arnei/opencast-admin-interface into r/19.x
Pull request #1496 Fix multi-select values in metadata not removable (Safari)
2 parents 6bc56f2 + 26aadd9 commit a89c999

2 files changed

Lines changed: 32 additions & 25 deletions

File tree

src/components/shared/wizard/RenderMultiField.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,26 @@ const ShowValue = ({
206206
showCheck,
207207
onBlur,
208208
}: {
209-
setEditMode: (e: boolean) => void
209+
setEditMode: (e: boolean) => void
210210
form: FieldProps["form"]
211211
field: FieldProps["field"]
212212
showCheck: boolean,
213213
onBlur: () => void
214214
}) => {
215215
return (
216-
<div
217-
tabIndex={0}
218-
onClick={() => setEditMode(true)}
219-
onFocus={() => setEditMode(true)} // <-- activate edit mode on focus
220-
onKeyDown={e => {
221-
if (e.key === "Enter" || e.key === " ") {
222-
setEditMode(true);
223-
e.preventDefault();
224-
}
225-
}}
226-
227-
onBlur={onBlur}
228-
className="show-edit"
229-
>
216+
<div
217+
tabIndex={0}
218+
onClick={() => setEditMode(true)}
219+
onFocus={() => setEditMode(true)} // <-- activate edit mode on focus
220+
onKeyDown={e => {
221+
if (e.key === "Enter" || e.key === " ") {
222+
setEditMode(true);
223+
e.preventDefault();
224+
}
225+
}}
226+
onBlur={onBlur}
227+
className="show-edit"
228+
>
230229
{field.value instanceof Array && field.value.length !== 0 ? (
231230
<ul>
232231
{field.value.map((item, key) => (

src/hooks/wizardHooks.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,24 @@ export const useClickOutsideField = (
113113
childRef.current.focus();
114114
}
115115

116-
const handleBlur = (e: FocusEvent) => {
117-
// Check if blur moves to an element outside childRef
118-
if (childRef.current && !childRef.current.contains(e.relatedTarget as Node)) {
119-
setEditMode(false);
120-
}
121-
};
122-
123-
if (childRef.current) {
124-
childRef.current.addEventListener("blur", handleBlur, true); // capture phase
125-
}
116+
/* TODO: Fix handleBlur
117+
This is supposed to handle blur for tab navigation, which it does.
118+
But it also triggers on mouse clicks that are inside the field, causing
119+
unintended blurs and sometimes other elements besides the input element
120+
to not work. A proper fix should properly set edit mode to false when the
121+
field is left via keyboard navigation, but not set edit mode to false when
122+
the user is clicking inside of the field.
123+
*/
124+
// const handleBlur = (e: FocusEvent) => {
125+
// // Check if blur moves to an element outside childRef
126+
// if (childRef.current && !childRef.current.contains(e.relatedTarget as Node)) {
127+
// setEditMode(false);
128+
// }
129+
// };
130+
131+
// if (childRef.current) {
132+
// childRef.current.addEventListener("blur", handleBlur, true); // capture phase
133+
// }
126134

127135
// Adding event listener for detecting click outside
128136
window.addEventListener("mousedown", handleClickOutside);

0 commit comments

Comments
 (0)