WordPress/WordPress · error · Error

Invalid "action" value, use either "copy" or "cut"

Error message

Invalid "action" value, use either "copy" or "cut"

What it means

Error "Invalid "action" value, use either "copy" or "cut"" thrown in WordPress/WordPress.

Source

Thrown at wp-includes/js/clipboard.js:161


/**
 * Inner function which performs selection from either `text` or `target`
 * properties and then executes copy or cut operations.
 * @param {Object} options
 */

var ClipboardActionDefault = function ClipboardActionDefault() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  // Defines base properties passed from constructor.
  var _options$action = options.action,
      action = _options$action === void 0 ? 'copy' : _options$action,
      container = options.container,
      target = options.target,
      text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.

  if (action !== 'copy' && action !== 'cut') {
    throw new Error('Invalid "action" value, use either "copy" or "cut"');
  } // Sets the `target` property using an element that will be have its content copied.


  if (target !== undefined) {
    if (target && _typeof(target) === 'object' && target.nodeType === 1) {
      if (action === 'copy' && target.hasAttribute('disabled')) {
        throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
      }

      if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
        throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
      }
    } else {
      throw new Error('Invalid "target" value, use a valid Element');
    }
  } // Define selection strategy based on `text` property.

View on GitHub (pinned to f37eb7ab38)

When it happens

Trigger: Thrown at wp-includes/js/clipboard.js:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of WordPress/WordPress@f37eb7ab38 (2026-08-17). Data as JSON: /api/errors/509be44cb8d3d5ca. Report an issue: GitHub.