@@ -63,6 +63,7 @@ export class JSONEditor implements ICellEditorComp {
6363 editor ! : PrismEditor ;
6464 saveBtn ! : HTMLButtonElement ;
6565 cancelBtn ! : HTMLButtonElement ;
66+ hideErrorsBtn ! : HTMLButtonElement ;
6667 focusManager ! : EditorFocusManager ;
6768
6869 init ( params : ICellEditorParams ) {
@@ -122,6 +123,7 @@ export class JSONEditor implements ICellEditorComp {
122123 editorContainer ,
123124 this . cancelBtn ,
124125 this . saveBtn ,
126+ this . hideErrorsBtn ,
125127 ) ;
126128 }
127129
@@ -163,14 +165,14 @@ export class JSONEditor implements ICellEditorComp {
163165 const errors = document . createElement ( "div" ) ;
164166 errors . className = `${ styles . errors } ${ styles . hidden } ` ;
165167 errors . setAttribute ( "role" , "alert" ) ;
166- const closeBtn = this . _createButton ( "✕" ) ;
167- closeBtn . setAttribute ( "aria-label" , "Dismiss error alert" ) ;
168- closeBtn . addEventListener ( "click" , ( ) => {
168+ this . hideErrorsBtn = this . _createButton ( "✕" ) ;
169+ this . hideErrorsBtn . setAttribute ( "aria-label" , "Dismiss error alert" ) ;
170+ this . hideErrorsBtn . addEventListener ( "click" , ( ) => {
169171 this . _hideError ( ) ;
170172 } ) ;
171173 this . errorMsgElement = document . createElement ( "div" ) ;
172174 this . errorMsgElement . className = styles [ "error-msg" ] ;
173- errors . append ( this . errorMsgElement , closeBtn ) ;
175+ errors . append ( this . errorMsgElement , this . hideErrorsBtn ) ;
174176 return errors ;
175177 }
176178
@@ -236,11 +238,13 @@ export class JSONEditor implements ICellEditorComp {
236238 // -------------^
237239 this . errorMsgElement . style . flexShrink = scrollLongLine ? "0" : "1" ;
238240 this . errorContainer . classList . remove ( styles . hidden ) ;
241+ this . focusManager . focusHideErrorsBtn ( ) ;
239242 }
240243
241244 _hideError ( ) {
242245 this . errorMsgElement . innerText = "" ;
243246 this . errorContainer . classList . add ( styles . hidden ) ;
247+ this . focusManager . excludeHideErrors ( ) ;
244248 }
245249
246250 _prettyPrint ( value : string | null | undefined ) {
@@ -264,10 +268,16 @@ class EditorFocusManager {
264268 public editorContainer : HTMLDivElement ,
265269 public cancel : HTMLButtonElement ,
266270 public save : HTMLButtonElement ,
271+ public hideErrors : HTMLButtonElement ,
272+ public includeHideErrors = false ,
267273 ) { }
268274
269275 get elements ( ) : HTMLElement [ ] {
270- return [ this . editorContainer , this . cancel , this . save ] ;
276+ const managedElements = [ this . editorContainer , this . cancel , this . save ] ;
277+ if ( this . includeHideErrors ) {
278+ managedElements . push ( this . hideErrors ) ;
279+ }
280+ return managedElements ;
271281 }
272282
273283 focusNext ( ) {
@@ -294,6 +304,16 @@ class EditorFocusManager {
294304 this . focusElement ( this . editorContainer ) ;
295305 }
296306
307+ focusHideErrorsBtn ( ) {
308+ this . includeHideErrors = true ;
309+ this . focusElement ( this . hideErrors ) ;
310+ }
311+
312+ excludeHideErrors ( ) {
313+ this . includeHideErrors = false ;
314+ this . focusElement ( this . save ) ;
315+ }
316+
297317 private focusElement ( elt : HTMLElement ) {
298318 if ( elt === this . editorContainer ) {
299319 const textarea =
0 commit comments