How to use the rc-util/lib/KeyCode.ESC function in rc-util

To help you get started, we’ve selected a few rc-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-component / dialog / src / Dialog.tsx View on Github external
onKeyDown = (e: React.KeyboardEvent) => {
    const props = this.props;
    if (props.keyboard && e.keyCode === KeyCode.ESC) {
      e.stopPropagation();
      this.close(e);
      return;
    }
    // keep focus inside dialog
    if (props.visible) {
      if (e.keyCode === KeyCode.TAB) {
        const activeElement = document.activeElement;
        const sentinelStart = this.sentinelStart;
        if (e.shiftKey) {
          if (activeElement === sentinelStart) {
            this.sentinelEnd.focus();
          }
        } else if (activeElement === this.sentinelEnd) {
          sentinelStart.focus();
        }
github react-component / select / src / OptionList.tsx View on Github external
const item = memoFlattenOptions[activeIndex];
          if (item && !(item.data as OptionData).disabled) {
            onSelectValue((item.data as OptionData).value);
          } else {
            onSelectValue(null);
          }

          if (open) {
            event.preventDefault();
          }

          break;
        }

        // >>> Close
        case KeyCode.ESC: {
          onToggleOpen(false);
        }
      }
    },
    onKeyUp: () => {},
github react-component / cascader / tests / keyboard.spec.js View on Github external
it(`${name} to open`, () => {
      wrapper.find('input').simulate('keyDown', { keyCode });
      expect(wrapper.find('.rc-cascader-menus-hidden').length).toBe(0);

      wrapper.find('input').simulate('keyDown', { keyCode: KeyCode.ESC });
      expect(wrapper.find('.rc-cascader-menus-hidden').length).toBe(1);
    });
  });
github react-component / calendar / tests / Picker.spec.jsx View on Github external
it('close by ESC key', () => {
    const picker = renderPicker();
    picker.find('.rc-calendar-picker-input').simulate('click');
    picker.find('.rc-calendar').simulate('keyDown', {
      keyCode: keyCode.ESC,
    });
    expect(picker.state().open).toBe(false);
  });
github react-component / dialog / tests / index.js View on Github external
}, (done) => {
      Simulate.keyDown($('.rc-dialog')[0], {
        keyCode: KeyCode.ESC,
      });
      setTimeout(done, 10);
    }, (done) => {
      expect(callback1).to.be(1);
github pingcap / tidb-dashboard / ui / lib / components / BaseSelect / index.tsx View on Github external
(ev: React.KeyboardEvent) => {
      if (ev.which === KeyCode.ENTER) {
        toggleDropdownVisible()
      } else if (ev.which === KeyCode.ESC) {
        setDropdownVisible(false)
      }
      onKeyDown && onKeyDown(ev)
    },
    [toggleDropdownVisible, onKeyDown]
github react-component / drawer / src / Drawer.js View on Github external
onKeyDown = e => {
    if (e.keyCode === KeyCode.ESC) {
      const { onMaskClick, onHandleClick } = this.props;
      e.stopPropagation();
      const onClose = onHandleClick || onMaskClick;
      if (onClose) {
        onClose(e);
      } else {
        this.onTouchEnd(e, true);
      }
    }
  };
github react-component / calendar / src / Picker.tsx View on Github external
onCalendarKeyDown = event => {
    if (event.keyCode === KeyCode.ESC) {
      event.stopPropagation();
      this.close(this.focus);
    }
  };
github godaner / vm-engine / vm-backend / src / main / resources / static / node_modules / rc-calendar / es / Picker.js View on Github external
onCalendarKeyDown: function onCalendarKeyDown(event) {
    if (event.keyCode === KeyCode.ESC) {
      event.stopPropagation();
      this.close(this.focus);
    }
  },
  onCalendarSelect: function onCalendarSelect(value) {
github react-component / select / src / Selector / index.tsx View on Github external
> = event => {
    const { which } = event;

    if (which === KeyCode.UP || which === KeyCode.DOWN) {
      event.preventDefault();
    }

    if (onInputKeyDown) {
      onInputKeyDown(event);
    }

    if (
      ![KeyCode.SHIFT, KeyCode.TAB, KeyCode.BACKSPACE, KeyCode.ESC].includes(
        which,
      )
    ) {
      onToggleOpen(true);
    }
  };