microsoft / microsoft/monaco-editor

How could I make an context menu disabled not hide

Open
#847 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contextmenu feature-request
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Hi all,

2018-04-25 3 31 34 2018-04-25 5 54 43
how could I make Redo in a disable style, not hide it?

my code:

this.undo = this.editor.createContextKey('undo', false);
this.redo = this.editor.createContextKey('redo', false);
this.editor.addAction({
      id: 'undo_model',
      label: 'Undo',
      keybindings: [
        monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_Z
      ],
      contextMenuGroupId: '9_cutcopypaste',
      contextMenuOrder: 0,
      precondition: 'undo',
      run: () => {
        this.editor.trigger('', 'undo');
      },
    });

    this.editor.addAction({
      id: 'redo_model',
      label: 'Redo',
      keybindings: [
        monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KEY_Z
      ],
      contextMenuGroupId: '9_cutcopypaste',
      contextMenuOrder: 0,
      precondition: 'redo',
      run: () => {
        this.editor.trigger('', 'redo');
      },
    });

Playground link

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior in the linked Monaco Playground using editor.createContextKey and editor.addAction with the undo and redo preconditions. Inspect how a false precondition affects the context menu. Done means the Redo action remains visible but disabled when redo is false.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.