Giter Site home page Giter Site logo

Comments (3)

lane-formio avatar lane-formio commented on April 27, 2024

This can actually be done on a per-form basis by adding keyboardBuilder = true as a custom property in form settings. The related PRs can be found here and [here] (formio/formio.js#5152).

image

from react.

DonAmit197 avatar DonAmit197 commented on April 27, 2024

@lane-formio , I have tried the way you suggested but it doesn't suffice my requirement, instead what I did I have added a tabindex="0" to the formcomponent

const sideBarBtns = document.querySelectorAll(".formcomponent.drag-copy");
  sideBarBtns.forEach((btn) => {
    //console.log(btn);
    btn.setAttribute("tabIndex", "0");
    btn.addEventListener("keydown", function (e) {
      performOnEnter(e);
    });
  });

and the tabIndex works fine. Now my intension is to open the Edit modal screen on "keydown" event. To make this happen I feel that I have to extend the WebformBuilder class. I'm importing the formiojs by var _formiojs = require("formiojs"); There I can see are few methods like initDragula, onDrop. Could you please suggest which method I should trigger?

Thanks in advance

from react.

DonAmit197 avatar DonAmit197 commented on April 27, 2024

At least got some success to open the edit modal on hitting the Enter key. Created a new method

WebformBuilder.default.prototype.addKeyBoardEvent = function () {
  console.log('ADDKEYB', this);
  this.refs['sidebar-component'].forEach((component) => {
    component.setAttribute('tabindex', '0');
    this.addEventListener(component, 'keydown', (event) => {
      if (event.keyCode === 13) {
        this.addNewComponent(component);
      }
    });
  });

  const componentEdit = this.componentEdit;
  const _self = this;
  if (componentEdit) {
    const removeBtn = componentEdit.querySelector('[ref="removeButton"]');
    removeBtn.addEventListener('keydown', (event) => {
      if (event.keyCode === 13) {
        console.log(this);
        //this.saved = true;
        //this.editForm.detach();
        //this.removeComponent();
        _self.dialog.close();
        //this.highlightInvalidComponents();
      }
    });
  }
};

called the method inside

WebformBuilder.default.prototype.initDragula = function () {
 this.addKeyBoardEvent();
}

But I can observe (however I can understand that I'm doing wrong somewhere) that on hitting the "Enter" key on the "Save" button it's not working. Throwing an error "Cannot read properties of null (reading 'component')" . Any idea or feedback on this? Appreciate any help. Thanks.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.