How to use the @material/dialog/util.createFocusTrapInstance function in @material/dialog

To help you get started, we’ve selected a few @material/dialog 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 posva / vue-mdc / src / Dialog / Dialog.vue View on Github external
mounted () {
    this.focusTrap_ = createFocusTrapInstance(this.$refs.surface, this.$refs.accept)
    this.foundation = new MDCDialogFoundation({
      addClass: (className) => this.$el.classList.add(className),
      removeClass: (className) => this.$el.classList.remove(className),
      addBodyClass: (className) => document.body.classList.add(className),
      removeBodyClass: (className) => document.body.classList.remove(className),
      eventTargetHasClass: (target, className) => target.classList.contains(className),
      registerInteractionHandler: (evt, handler) => this.$el.addEventListener(evt, handler),
      deregisterInteractionHandler: (evt, handler) => this.$el.removeEventListener(evt, handler),
      registerSurfaceInteractionHandler: (evt, handler) => this.$refs.surface.addEventListener(evt, handler),
      deregisterSurfaceInteractionHandler: (evt, handler) => this.$refs.surface.removeEventListener(evt, handler),
      registerDocumentKeydownHandler: (handler) => document.addEventListener('keydown', handler),
      deregisterDocumentKeydownHandler: (handler) => document.removeEventListener('keydown', handler),
      registerTransitionEndHandler: (handler) => this.$refs.surface.addEventListener('transitionend', handler),
      deregisterTransitionEndHandler: (handler) => this.$refs.surface.removeEventListener('transitionend', handler),
      notifyAccept: () => this.$emit('accepted'),
      notifyCancel: () => this.$emit('canceled'),
github material-components / material-components-web-react / packages / dialog / index.tsx View on Github external
private initializeFocusTrap = (): void => {
    this.focusTrap = this.props.children && createFocusTrapInstance(this.dialogElement.current!);
  };
github pgbross / vue-material-adapter / packages / mcwv-dialog / dialog.js View on Github external
onOpen_(value) {
      if (value) {
        if (this.$refs.container) {
          this.focusTrap = util.createFocusTrapInstance(
            this.$el,
            void 0,
            this.getInitialFocusEl_() || void 0,
          );
        }
        this.foundation.open();
      } else {
        this.foundation.close();
      }
    },
    onCancel() {
github pgbross / vue-material-adapter / packages / mcwv-dialog / mdc-dialog.js View on Github external
onOpen_(value) {
      if (value) {
        if (this.$refs.container) {
          this.focusTrap = util.createFocusTrapInstance(
            this.$el,
            createFocusTrap,
          );
        }
        this.foundation.open();
      } else {
        this.foundation.close();
      }
    },