When the panel is closed, the corresponding dom will not be closed

I’m not sure what’s causing this。my code:

openCustomPanel(view) {
      const self = this
      if(!this.togglePanel) {
        this.togglePanel = StateEffect.define()
      }
      if(!this.helpPanelState) {
        this.helpPanelState = StateField.define({
          create: () => false,
          update(value, tr) {
            for (let effect of tr.effects) {
              if (effect.is(self.togglePanel)) {
                value = effect.value;
              }
            }
            return value;
          },
          provide: f => showPanel.from(f, on => {
            return this.createHelpPanel
          })
        })
      }
      let state = view.state.field(this.helpPanelState, false);
      let newPanelEffect = null
      if(state) {
        newPanelEffect = self.togglePanel.of(self.helpPanelState)
      } else {
        newPanelEffect = StateEffect.appendConfig.of([self.helpPanelState])
      }
      view.dispatch({
        effects: [
          self.togglePanel.of(true),
          newPanelEffect
        ]
      });
      return true;
    },

this is my close panel method:

closeSearchPanel(view){

      let state = view.state.field(this.helpPanelState, false);

      if (!state) {

        return false;

      }

      view.dispatch({

        effects: this.togglePanel.of(false)

      });

      return true;

    },

This ignores on and always returns the panel, so that might explain why you are seeing it regardless of the field’s value.

Thanks for the reply and the tip, hmm. . . . , I can use this parameter to return a null when it is false