File tree Expand file tree Collapse file tree
events/partials/ModalTabsAndPages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ const NewMetadataPage = ({
1818 header ?: ParseKeys
1919} ) => {
2020 const { t } = useTranslation ( ) ;
21- console . log ( metadataCatalogs ) ;
2221 return (
2322 < ModalContentTable >
2423 {
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ const DropDown = <T, >({
209209 < AsyncSelect
210210 ref = { selectRef }
211211 { ...commonProps }
212- openMenuOnFocus = { false }
212+ openMenuOnFocus = { false }
213213 noOptionsMessage = { ( ) => t ( "SELECT_NO_MATCHING_RESULTS" ) }
214214 cacheOptions
215215 defaultOptions = { formatOptions (
Original file line number Diff line number Diff line change @@ -83,9 +83,7 @@ const RenderMultiField = ({
8383
8484 // reset inputValue
8585 setInputValue ( "" ) ;
86- } else {
87- setEditMode ( false ) ;
88- }
86+ }
8987 } ;
9088
9189 // Remove item/value from inserted field values
@@ -118,6 +116,10 @@ const RenderMultiField = ({
118116 field = { field }
119117 form = { form }
120118 showCheck = { showCheck }
119+ onBlur = { ( ) => {
120+ submitValue ( ) ;
121+ setEditMode ( false ) ;
122+ } }
121123 />
122124 )
123125 ) ;
@@ -199,16 +201,26 @@ const ShowValue = ({
199201 form : { initialValues } ,
200202 field,
201203 showCheck,
204+ onBlur,
202205} : {
203- setEditMode : ( e : boolean ) => void
206+ setEditMode : ( e : boolean ) => void
204207 form : FieldProps [ "form" ]
205208 field : FieldProps [ "field" ]
206209 showCheck : boolean ,
210+ onBlur : ( ) => void
207211} ) => {
208212 return (
209213 < div
210214 tabIndex = { 0 }
211215 onClick = { ( ) => setEditMode ( true ) }
216+ onFocus = { ( ) => setEditMode ( true ) } // <-- activate edit mode on focus
217+ onKeyDown = { e => {
218+ if ( e . key === "Enter" || e . key === " " ) {
219+ setEditMode ( true ) ;
220+ e . preventDefault ( ) ;
221+ }
222+ } }
223+ onBlur = { onBlur }
212224 className = "show-edit"
213225 >
214226 { field . value instanceof Array && field . value . length !== 0 ? (
Original file line number Diff line number Diff line change @@ -118,6 +118,17 @@ export const useClickOutsideField = (
118118 childRef . current . focus ( ) ;
119119 }
120120
121+ const handleBlur = ( e : FocusEvent ) => {
122+ // Check if blur moves to an element outside childRef
123+ if ( childRef . current && ! childRef . current . contains ( e . relatedTarget as Node ) ) {
124+ setEditMode ( false ) ;
125+ }
126+ } ;
127+
128+ if ( childRef . current ) {
129+ childRef . current . addEventListener ( "blur" , handleBlur , true ) ; // capture phase
130+ }
131+
121132 // Adding event listener for detecting click outside
122133 window . addEventListener ( "mousedown" , handleClickOutside ) ;
123134
You can’t perform that action at this time.
0 commit comments