How to use the @zendeskgarden/container-utilities.KEY_CODES.ESCAPE function in @zendeskgarden/container-utilities

To help you get started, we’ve selected a few @zendeskgarden/container-utilities 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 zendeskgarden / react-components / packages / modals / src / elements / Modal.spec.js View on Github external
it('is triggered by ESC keydown', () => {
      const { getByTestId } = render();

      fireEvent.keyDown(getByTestId('modal'), { keyCode: KEY_CODES.ESCAPE });
      expect(onCloseSpy).toHaveBeenCalled();
    });
  });
github zendeskgarden / react-components / packages / datepickers / src / Datepicker / Datepicker.spec.tsx View on Github external
it('closes datepicker when correct keys are used', () => {
      const { getByTestId, queryByTestId } = render(
        
      );
      const input = getByTestId('input');

      fireEvent.mouseDown(getByTestId('input'));
      fireEvent.click(input);
      fireEvent.keyDown(input, { keyCode: KEY_CODES.ESCAPE });

      expect(queryByTestId('datepicker-menu')).toBeNull();

      fireEvent.mouseDown(getByTestId('input'));
      fireEvent.click(input);
      fireEvent.keyDown(input, { keyCode: KEY_CODES.ENTER });
      expect(queryByTestId('datepicker-menu')).toBeNull();
    });
github zendeskgarden / react-containers / packages / modal / src / ModalContainer.spec.tsx View on Github external
it('closes modal when ESC is pressed', () => {
        const { getByTestId } = render();

        fireEvent.keyDown(getByTestId('modal'), { keyCode: KEY_CODES.ESCAPE });
        expect(onCloseSpy).toHaveBeenCalled();
      });
github zendeskgarden / react-containers / packages / tooltip / src / useTooltip.ts View on Github external
onKeyDown: composeEventHandlers(onKeyDown, (event: KeyboardEvent) => {
        if (event.keyCode === KEY_CODES.ESCAPE && visibility) {
          closeTooltip(0);
        }
      }),
      'aria-describedby': _id,
github zendeskgarden / react-containers / packages / modal / src / useModal.ts View on Github external
onKeyDown: composeEventHandlers(onKeyDown, (event: KeyboardEvent) => {
        if (event.keyCode === KEY_CODES.ESCAPE) {
          closeModal(event);
        }
      }),
      ...other
github zendeskgarden / react-components / packages / datepickers / src / Datepicker / Datepicker.tsx View on Github external
onKeyDown: e => {
                switch (e.keyCode) {
                  case KEY_CODES.ESCAPE:
                  case KEY_CODES.ENTER:
                    dispatch({ type: 'CLOSE' });
                    break;
                  case KEY_CODES.UP:
                  case KEY_CODES.DOWN:
                  case KEY_CODES.SPACE:
                    dispatch({ type: 'OPEN' });
                    break;
                }
              },
              autoComplete: 'off',