KioskBoard icon indicating copy to clipboard operation
KioskBoard copied to clipboard

[FEAT] - Add close button

Open Int32Overflow opened this issue 2 years ago • 4 comments

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 avatar May 19 '22 16:05 Int32Overflow

Yes please. This would be great!

pindab0ter avatar Aug 24 '22 10:08 pindab0ter

@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

DanielKoohmarey avatar Oct 01 '22 23:10 DanielKoohmarey

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

furcan avatar Oct 03 '22 14:10 furcan

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();
                  }

DanielKoohmarey avatar Oct 03 '22 16:10 DanielKoohmarey

https://github.com/furcan/KioskBoard/releases/tag/v2.3.0

furcan avatar Oct 16 '22 20:10 furcan