From d46692fe5bd6b3fb36d5ae0b1ead1fb4f64346e2 Mon Sep 17 00:00:00 2001 From: Michele Giorgi Date: Sun, 30 Jan 2022 16:07:10 +0100 Subject: [PATCH] minor fixes --- assets/scripts/public/fields/textarea.js | 9 ++++++--- assets/scripts/public/modules/conditional.js | 2 +- assets/scripts/public/modules/fields.js | 2 +- formality.php | 4 ++-- includes/class-formality.php | 2 +- package.json | 2 +- readme.txt | 11 ++++++++++- webpack.mix.js | 2 +- 8 files changed, 23 insertions(+), 11 deletions(-) diff --git a/assets/scripts/public/fields/textarea.js b/assets/scripts/public/fields/textarea.js index fc13131..8594dc3 100644 --- a/assets/scripts/public/fields/textarea.js +++ b/assets/scripts/public/fields/textarea.js @@ -11,11 +11,14 @@ export const fieldTextarea = (field) => { lineHeight = parseInt(lineHeight.replace('px', '')) textarea.value = savedValue const minRows = textarea.rows - const maxLength = parseInt(textarea.getAttribute('maxlength')) - const counterHtml = `
${ savedValue.length } / ${ maxLength }
` + const maxLength = textarea.getAttribute('maxlength') ? ' / ' + parseInt(textarea.getAttribute('maxlength')) : '' + const counterHtml = maxLength ? `
${ savedValue.length + maxLength }
` : '' textarea.insertAdjacentHTML('beforebegin', counterHtml) textarea.addEventListener('input', (e) => { - textarea.previousElementSibling.innerText = textarea.value.length + ' / ' + maxLength + const counter = textarea.previousElementSibling + if(counter) { + counter.innerText = textarea.value.length + maxLength + } textarea.rows = minRows const newRows = Math.ceil((textarea.scrollHeight - baseScrollHeight) / lineHeight) textarea.rows = minRows + newRows diff --git a/assets/scripts/public/modules/conditional.js b/assets/scripts/public/modules/conditional.js index be27598..e5856a7 100644 --- a/assets/scripts/public/modules/conditional.js +++ b/assets/scripts/public/modules/conditional.js @@ -4,7 +4,7 @@ export let initConditionalField = (form, field) => { if(!field.hasAttribute('data-conditional')) return let query = '' const rule = JSON.parse(field.getAttribute('data-conditional')) - for (const index in rule) { query += ( index == 0 ? '' : ', ' ) + '[name=' + rule[index].field + ']' } + for (const index in rule) { query += ( index == 0 ? '' : ', ' ) + '[name="' + rule[index].field + '"]' } if(query) { checkCondition(form, field, rule) const inputs = form.querySelectorAll(query) diff --git a/assets/scripts/public/modules/fields.js b/assets/scripts/public/modules/fields.js index 3bd0ea1..a0f8fa7 100644 --- a/assets/scripts/public/modules/fields.js +++ b/assets/scripts/public/modules/fields.js @@ -51,7 +51,7 @@ export let inputKeypress = (input, field, conversational) => { export let moveField = (input, field, direction='next', e, conversational=false) => { let element = false - const visible = cl('field:not(' + cl('field', 'disabled') + ')') + const visible = cl('field:not(' + cl('field', '', 'disabled') + ')') switch (direction) { case 'next': element = nextEl(field, visible) diff --git a/formality.php b/formality.php index 69bbfa7..1bb7731 100755 --- a/formality.php +++ b/formality.php @@ -12,7 +12,7 @@ * Plugin Name: Formality * Plugin URI: https://formality.dev * Description: Forms made simple (and cute). Designless, multistep, conversational, secure, all-in-one WordPress forms plugin. - * Version: 1.5.1 + * Version: 1.5.2 * Author: Michele Giorgi * Author URI: https://giorgi.io * License: GPLv3 @@ -47,7 +47,7 @@ /** * Currently plugin version. */ -define('FORMALITY_VERSION', '1.5.1'); +define('FORMALITY_VERSION', '1.5.2'); define('FORMALITY_PATH', plugin_dir_path( __FILE__ )); /** diff --git a/includes/class-formality.php b/includes/class-formality.php index 9ea5140..fa661e2 100755 --- a/includes/class-formality.php +++ b/includes/class-formality.php @@ -57,7 +57,7 @@ class Formality { */ public function __construct() { - $this->version = defined( 'FORMALITY_VERSION' ) ? FORMALITY_VERSION : '1.5.1'; + $this->version = defined( 'FORMALITY_VERSION' ) ? FORMALITY_VERSION : '1.5.2'; $this->formality = 'formality'; $this->fse = class_exists('WP_Block_Editor_Context'); diff --git a/package.json b/package.json index e4771cd..09092a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Formality", - "version": "1.5.1", + "version": "1.5.2", "author": "Michele Giorgi ", "homepage": "https://giorgi.io", "private": true, diff --git a/readme.txt b/readme.txt index 3d1cea7..49d4370 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/michelegiorgi/ Tags: form, conversational, multistep, design form, gutenberg, block editor Requires at least: 5.8 Tested up to: 5.9 -Stable tag: 1.5.1 +Stable tag: 1.5.2 Requires PHP: 7.2 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.txt @@ -61,6 +61,15 @@ You will find **Formality** menu in your WordPress admin screen. == Changelog == += 1.5.2 = +Release Date: Jan 30th, 2022 + +* Fix conditional fields init ¹ +* Remove characters counter from textarea field when max length is not defined +* Fix keyboard navigation with hidden fields + +¹ Thanks to @lukaskopenec for bug report + = 1.5.1 = Release Date: Jan 16th, 2022 diff --git a/webpack.mix.js b/webpack.mix.js index 0815d2f..5dc34e8 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -16,7 +16,7 @@ mix .js('assets/scripts/public/index.js', 'scripts/formality-public.js') .js('assets/scripts/editor/index.js', 'scripts/formality-editor.js') .js('assets/scripts/admin/index.js', 'scripts/formality-admin.js') - .banner({ banner: 'Formality v1.5.1' }); + .banner({ banner: 'Formality v1.5.2' }); mix .copyWatched('assets/images/admin/**', 'dist/images/admin')