@vention/machine-logic-ui-sdk 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.esm.js +15 -3
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1814,21 +1814,33 @@ const VirtualKeyboard = () => {
1814
1814
  const [keyboardLayout, setKeyboardLayout] = useState(KeyboardLayout.TEXT);
1815
1815
  const [keyboardLayoutName, setKeyboardLayoutName] = useState(KeyboardLayoutName.DEFAULT);
1816
1816
  const [focusedTextInput, setFocusedTextInput] = useState();
1817
+ const [isSubmitPressed, setIsSubmitPressed] = useState(false);
1817
1818
  const virtualKeyboardRef = useRef(null);
1818
1819
  const keyboardContainerRef = useRef(null);
1819
- useEffect(function handleClickOutsideListeners() {
1820
+ useEffect(function handleClickListeners() {
1820
1821
  function handleClickOutside(event) {
1821
1822
  if (keyboardContainerRef.current && !keyboardContainerRef.current.contains(event.target)) {
1822
1823
  setIsKeyboardVisible(false);
1823
1824
  }
1824
1825
  }
1826
+ function handleMouseOrTouchUp(event) {
1827
+ if (isSubmitPressed) {
1828
+ event.preventDefault();
1829
+ setIsKeyboardVisible(false);
1830
+ setIsSubmitPressed(false);
1831
+ }
1832
+ }
1825
1833
  document.addEventListener("mousedown", handleClickOutside);
1826
1834
  document.addEventListener("touchstart", handleClickOutside);
1835
+ document.addEventListener("mouseup", handleMouseOrTouchUp);
1836
+ document.addEventListener("touchend", handleMouseOrTouchUp);
1827
1837
  return () => {
1828
1838
  document.removeEventListener("mousedown", handleClickOutside);
1829
1839
  document.removeEventListener("touchstart", handleClickOutside);
1840
+ document.removeEventListener("mouseup", handleMouseOrTouchUp);
1841
+ document.removeEventListener("touchend", handleMouseOrTouchUp);
1830
1842
  };
1831
- }, []);
1843
+ }, [isSubmitPressed]);
1832
1844
  useEffect(function showOrHideKeyboard() {
1833
1845
  // The keyboard will appear/disappear on mouse down
1834
1846
  // However, if the user is clicking something, like a submit button or the input itself, the mouse up will happen a few milliseconds after the keyboard is shown/hidden
@@ -1969,7 +1981,7 @@ const VirtualKeyboard = () => {
1969
1981
  break;
1970
1982
  case KeyboardKey.SUBMIT:
1971
1983
  focusedTextInput.blur();
1972
- setIsKeyboardVisible(false);
1984
+ setIsSubmitPressed(true);
1973
1985
  break;
1974
1986
  }
1975
1987
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-logic-ui-sdk",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"