Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] - Add close button #55

Closed
Int32Overflow opened this issue May 19, 2022 · 5 comments
Closed

[FEAT] - Add close button #55

Int32Overflow opened this issue May 19, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Int32Overflow
Copy link

A few users have the problem that they do not know how to close the keyboard.
Therefore, in my opinion, it would make sense to offer a "close button" that is displayed at the top right.
Another option would be a "confirmation button" (e.g. Confirm, OK, Apply).

@Int32Overflow Int32Overflow added the enhancement New feature or request label May 19, 2022
@pindab0ter
Copy link

Yes please. This would be great!

@DanielKoohmarey
Copy link

DanielKoohmarey commented Oct 1, 2022

@furcan I can implement this if you can just point me to the current callback that hides/closes the keyboard? which func is this? How would i call it from console if a keyboard was currently open? I believe its here: https://github.com/furcan/KioskBoard/blob/main/src/kioskboard.js#L809

@furcan
Copy link
Owner

furcan commented Oct 3, 2022

Hi @DanielKoohmarey
It is required to create a common function for hiding and removing the keyboard first.
Then we need to use this common function for the exact line that you have mentioned and with the new close button onclick event.
Especially because of the new button design and position, I am willing to do it by myself(ASAP). But I will also add you to the PR 🙏
Best wishes,
Furkan

@DanielKoohmarey
Copy link

DanielKoohmarey commented Oct 3, 2022

Appreciate you planning to do this! I had managed to refactor it for my use case with the same plan, creating a common func first. There are a lot of variable dependencies that need to be refactored, I would recommend you store the keyboard options in the window keyboard object so they are accessible. There is also the doc listener you may need to store somewhere to call within the remove func:

        var removeKeyboard = function() {
              var cssAnimationsStyle = 'kioskboard-slide'; //'kioskboard-fade'
              var cssAnimationsDuration = 360;
      
              var keyboardElement = window.document.getElementById('KioskBoard-VirtualKeyboard');
              if (keyboardElement) {
                  // add remove class
                  keyboardElement.classList.add(cssAnimationsStyle + '-remove');
                  
                  // remove after the animation has been ended
                  var removeTimeout = setTimeout(function () {
                      if (keyboardElement.parentNode !== null) {
                          keyboardElement.parentNode.removeChild(keyboardElement); // remove keyboard
                          window.document.body.classList.remove('kioskboard-body-padding'); // remove body padding class
                          window.document.removeEventListener('click', window.docClickListener); // remove document click listener
                      }
                      clearTimeout(removeTimeout);
                      }, cssAnimationsDuration);
              }
    };

...

              window.docClickListener = function (e) {
                var docClickTimeout = setTimeout(function () {
                  if (
                    e.target !== theInput &&
                    !kioskBoardEventTargetIsElementOrChilds(e, keyboardElement) &&
                    !e.target.classList.contains('kioskboard-body-padding')
                  ) {
                    removeKeyboard();
                  }

@furcan furcan added this to the v2.3.0 milestone Oct 16, 2022
furcan added a commit that referenced this issue Oct 16, 2022
@furcan furcan mentioned this issue Oct 16, 2022
@furcan
Copy link
Owner

furcan commented Oct 16, 2022

@furcan furcan closed this as completed Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants