diff --git a/package.json b/package.json
index 8a8257ebd..673a029ba 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,9 @@
"precommit": "lint-staged",
"e2e:ui": "playwright test --ui",
"start:app": "turbo run build --filter formik... && yarn --cwd packages/formik link && yarn --cwd ./app link formik && yarn --cwd ./app && yarn --cwd ./app run dev",
- "benchmark": "tsx scripts/benchmark.tsx | tee output.txt"
+ "benchmark": "tsx scripts/benchmark.tsx | tee output.txt",
+ "custom-build": "turbo run build --force",
+ "custom-publish": "bash ./scripts/custom-publish.sh"
},
"lint-staged": {
"**/*.{ts,tsx,md,mdx,js,jsx}": [
diff --git a/packages/formik/README.md b/packages/formik/README.md
index 8105b49d0..731e97038 100644
--- a/packages/formik/README.md
+++ b/packages/formik/README.md
@@ -1,3 +1,26 @@
+# Formik Fork README
+
+This is a Fork of the original Formik repository. It is intended to be used as a dependency in other projects with minimal changes to address bugs, since the original repository is not actively maintained (as of March 2025).
+
+The `main` branch contains the original Formik codebase, while the `main-dev` branch is the main development branch for this fork.
+
+This Fork has a `custom-publish` script.
+
+```bash
+yarn custom-publish
+```
+
+This should be called from the `main-dev` branch after making/merging changes to the codebase. The script builds the package and updates a dedicated `custom-build` branch containing only the distributable files. It then commits and force‑pushes these changes to GitHub, allowing you to continuously install the latest build with:
+
+```bash
+yarn add git+https://github.com/zduvall/formik.git#custom-build
+```
+
+Note that the `custom-publish` script uses the `custom-build` script which forces a build even if there are no detected changes.
+---
+
+# Formik Original README
+
diff --git a/packages/formik/src/Formik.tsx b/packages/formik/src/Formik.tsx
index ea36e80d3..d3b241d48 100755
--- a/packages/formik/src/Formik.tsx
+++ b/packages/formik/src/Formik.tsx
@@ -687,6 +687,8 @@ export function useFormik({
const executeBlur = React.useCallback(
(e: any, path?: string) => {
+ if (!e) return
+
if (e.persist) {
e.persist();
}
diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh
new file mode 100644
index 000000000..0e90b3784
--- /dev/null
+++ b/scripts/custom-publish.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+# Exit immediately on error, and treat unset variables as errors.
+set -euo pipefail
+
+# Color definitions.
+GREEN="\033[0;32m"
+YELLOW="\033[0;33m"
+BLUE="\033[0;34m"
+RED="\033[0;31m"
+NC="\033[0m" # No Color
+
+# Custom echo function to add newlines before and after the string.
+custom_echo() {
+ echo -e "\n$1\n"
+}
+
+# Check that we are in a Git repository.
+if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
+ custom_echo "${RED}[ERROR]${NC} Not inside a Git repository. Exiting."
+ exit 1
+fi
+
+# Ensure a clean working directory.
+if [ -n "$(git status --porcelain)" ]; then
+ custom_echo "${RED}[ERROR]${NC} Working directory is not clean. Please commit or stash your changes."
+ exit 1
+fi
+
+# Save the current branch name.
+ORIGINAL_BRANCH=$(git symbolic-ref --short HEAD)
+custom_echo "${BLUE}[INFO]${NC} Current branch: ${GREEN}${ORIGINAL_BRANCH}${NC}"
+
+# Create a temporary directory for the build output.
+TMP_DIR=$(mktemp -d -t custom-build-XXXXXXXX)
+custom_echo "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}"
+
+# Ensure the branch is switched back and the temporary directory is removed on exit.
+function cleanup {
+ CURRENT=$(git symbolic-ref --short HEAD)
+ if [ "$CURRENT" != "$ORIGINAL_BRANCH" ]; then
+ custom_echo "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${ORIGINAL_BRANCH}${NC}..."
+ git checkout "$ORIGINAL_BRANCH" || custom_echo "${RED}[ERROR]${NC} Failed to switch back to original branch."
+ else
+ custom_echo "${YELLOW}[CLEANUP]${NC} Already on the original branch: ${GREEN}${ORIGINAL_BRANCH}${NC}."
+ fi
+
+ custom_echo "${YELLOW}[CLEANUP]${NC} Removing temporary directory..."
+ rm -rf "$TMP_DIR"
+}
+trap cleanup EXIT
+
+# Run the build.
+custom_echo "${BLUE}[BUILD]${NC} Running build..."
+yarn custom-build
+
+# Verify the build output exists.
+if [ ! -d "packages/formik/dist" ]; then
+ custom_echo "${RED}[ERROR]${NC} Build output directory 'packages/formik/dist' does not exist. Exiting."
+ exit 1
+fi
+
+# Copy the built package to the temporary directory.
+custom_echo "${BLUE}[BUILD]${NC} Copying built package to temporary directory..."
+# copy everything from the built package to the temporary directory
+cp -R packages/formik/. "$TMP_DIR/"
+# copy the .git-ignore file to the temporary directory
+cp .gitignore "$TMP_DIR/"
+# delete the node_modules/ and test/ directories in the temporary directory
+rm -rf "$TMP_DIR/node_modules" "$TMP_DIR/test"
+
+# Check if the custom-build branch exists. If yes, checkout; if not, create it.
+if git rev-parse --verify custom-build >/dev/null 2>&1; then
+ custom_echo "${BLUE}[BRANCH]${NC} Branch 'custom-build' exists. Checking it out..."
+ git checkout custom-build
+else
+ custom_echo "${BLUE}[BRANCH]${NC} Branch 'custom-build' does not exist. Creating orphan branch..."
+ git checkout --orphan custom-build
+ # add an initial empty commit to the branch
+ git commit --allow-empty -m "Initial commit"
+fi
+
+# Remove all files from the branch.
+custom_echo "${BLUE}[BRANCH]${NC} Clearing files from 'custom-build' branch..."
+git rm -rf . > /dev/null 2>&1 || true
+
+# Copy the built files into the branch root.
+custom_echo "${BLUE}[DEPLOY]${NC} Copying built files to branch root..."
+cp -R "$TMP_DIR/." .
+
+# Stage and commit the changes.
+custom_echo "${BLUE}[DEPLOY]${NC} Staging files..."
+git add .
+# Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory
+git add -f dist/
+custom_echo "${BLUE}[DEPLOY]${NC} Committing build..."
+git commit -m "Auto commit -- publish custom build"
+
+# Force-push the branch to origin.
+custom_echo "${BLUE}[DEPLOY]${NC} Pushing 'custom-build' branch to origin..."
+git push -f origin custom-build
+
+custom_echo "${GREEN}[SUCCESS]${NC} Custom publish completed successfully!"