@@ -42,8 +42,8 @@ export class ConstraintMenu extends AbstractUIExtension implements Switchable {
4242 this . constraintRegistry = constraintRegistry ;
4343 this . tree = new AutoCompleteTree ( TreeBuilder . buildTree ( modelSource , labelTypeRegistry ) ) ;
4444 this . forceReadOnly = editorModeController ?. getCurrentMode ( ) !== "edit" ;
45- editorModeController ?. onModeChange ( ( mode ) => {
46- this . forceReadOnly = mode !== "edit" ;
45+ editorModeController ?. onModeChange ( ( _ ) => {
46+ this . forceReadOnly = editorModeController ! . isReadOnly ( ) ;
4747 } ) ;
4848 }
4949
@@ -58,7 +58,7 @@ export class ConstraintMenu extends AbstractUIExtension implements Switchable {
5858 containerElement . innerHTML = `
5959 <input type="checkbox" id="expand-state-constraint" class="accordion-state" hidden>
6060 <label id="constraint-menu-expand-label" for="expand-state-constraint">
61- <div class="accordion-button cevron-left" id="constraint-menu-expand-title">
61+ <div class="accordion-button cevron-left flip-arrow " id="constraint-menu-expand-title">
6262 Constraints
6363 </div>
6464 </label>
@@ -110,6 +110,10 @@ export class ConstraintMenu extends AbstractUIExtension implements Switchable {
110110 readOnly : this . constraintRegistry . getConstraints ( ) . length === 0 || this . forceReadOnly ,
111111 } ) ;
112112
113+ this . editor ?. setValue (
114+ this . constraintRegistry . getConstraints ( ) [ 0 ] ?. constraint ?? "Select or create a constraint to edit" ,
115+ ) ;
116+
113117 this . editor ?. onDidChangeModelContent ( ( ) => {
114118 if ( this . selectedConstraint ) {
115119 this . selectedConstraint . constraint = this . editor ?. getValue ( ) ?? "" ;
@@ -189,20 +193,21 @@ export class ConstraintMenu extends AbstractUIExtension implements Switchable {
189193
190194 const deleteButton = document . createElement ( "button" ) ;
191195 deleteButton . innerHTML = '<span class="codicon codicon-trash"></span>' ;
192- deleteButton . onclick = ( ) => {
193- this . constraintRegistry . unregisterConstraint ( constraint ) ;
194- this . rerenderConstraintList ( ) ;
195- if ( this . selectedConstraint === constraint ) {
196+ deleteButton . onclick = ( e ) => {
197+ e . stopPropagation ( ) ;
198+ if ( this . selectedConstraint ?. id === constraint . id ) {
196199 this . selectConstraintListItem ( undefined ) ;
197200 }
201+ this . constraintRegistry . unregisterConstraint ( constraint ) ;
202+ this . rerenderConstraintList ( ) ;
198203 } ;
199204 valueElement . appendChild ( deleteButton ) ;
200205 return valueElement ;
201206 }
202207
203208 private selectConstraintListItem ( constraint ?: Constraint ) : void {
204209 this . selectedConstraint = constraint ;
205- this . editor ?. setValue ( constraint ?. constraint ?? "" ) ;
210+ this . editor ?. setValue ( constraint ?. constraint ?? "Select or create a constraint to edit " ) ;
206211 this . editor ?. updateOptions ( { readOnly : constraint === undefined || this . forceReadOnly } ) ;
207212 }
208213
@@ -220,9 +225,9 @@ export class ConstraintMenu extends AbstractUIExtension implements Switchable {
220225 addButton . classList . add ( "constraint-add" ) ;
221226 addButton . innerHTML = '<span class="codicon codicon-add"></span> Constraint' ;
222227 addButton . onclick = ( ) => {
223- /* if (this.editorModeController?.isReadOnly() ) {
228+ if ( this . forceReadOnly ) {
224229 return ;
225- }*/
230+ }
226231 if ( ! list ) {
227232 return ;
228233 }
0 commit comments