• Resolved bogosavljev

    (@bogosavljev)


    Hi,

    I’m trying to add a footnote in WPForms, but it looks like it has some compatibility issue.

    If you check this survey page you will see that footnote is added at beginning (1) and at the end (2) of the question (I have added footnote just at the end as a shorcode [ref]New footnots[/ref]).

    Also, when you click on 1 or 2, in the console I’m getting jquery error:

    Uncaught Error: Syntax error, unrecognized expression: [name=f+11788+1+2]

    What could be a problem?

    WordPress 5.7, Divi 4.9.2 theme, WPForms 1.6.5.1

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi @bogosavljev,

    Thanks for the topic. That is due to WPForms repeating the label text—with the footnote—as value of the value argument of the checkbox input element, making for the fake footnote occurring at label start with the rest of the opening tag.

    I’ve tried to fix a copy of this page but the console error keeps occurring despite jQuery isn’t even meant to handle this fragment identifier used in hard links, that are enabled. Consistently scrolling by jQuery is broken, and what we get is default link scrolling. The defined scroll offset of 20% window height doesn’t work either. Never seen a heap of bugs like this during the five months I’m trying to help fix bugs in this plugin.

    To fix the first issue, the plugin should delete all footnotes found in the value of an input element, or any argument value to begin with, since this isn’t where footnotes are expected to be, given their content is provided as a footnote.

    Eventually the problem could be solved by adding a filter to WPForms so that it skips footnotes when extracting input element values in the first place.

    Best would be there is a way to input the element values when setting up the forms, as opposed to the plugin using the label text for that purpose.

    Basically Footnotes shouldn’t look for footnotes inside HTML tags, and search only inner text, so I’ve started looking for a regex doing this.

    Eventually using footnote delimiters bracketed with plain pointy brackets could do a trick of getting them stripped off when WPForms processes the label text to make an input element value out of it. To do so, you need to add the footnotes in plain text mode, either in the Block Editor or in the Classic Editor. (On a side note: The predefined delimiters with pointy brackets stopped working in the Block Editor because of unbalanced escapement, where the closing pointy brackets are not escaped, as allowed by the HTML spec.)

    Hopefully one or another fix will be running soon and make it into upcoming v2.6.0 where Footnotes will have an AMP compatibility mode and improve accessibility of footnotes lists, footnote referrers and referrer tooltips.

    Thank you for reporting this bug (that I wasn’t aware of)!

    Best regards.

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Thread Starter bogosavljev

    (@bogosavljev)

    Hi @pewgeuges,

    Will you help if I provide you a WordPress access to take a look?
    I have a client who is eager to use your plugin. When we can expect a new version?

    Thanks,
    Djuka

    Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi Djuka,

    Thanks for the follow-up. Upcoming Footnotes v2.6.0 is currently available as v2.6.0d7 at https://downloads.wordpress.org/plugin/footnotes.zip but I apologize for not fixing the WPForms bug yet, as I was busy all the time debugging the accessibility fixes in response to the preceding topic and aren’t done yet.

    So what we’ll do is to put 2.6.0 on standby and try to get the WPForms bug fixed in a v2.5.11 based on 2.5.10 and make it available as a tagged version but without changing the Stable Tag, with respect to Footnotes users impacted by too frequent releases since I caused a weird bug on November 2, and after a heavy release accident on March 1st on top of all that.

    After failing to download WPForms in response to your first post, would it make sense that I install the lite version and try to get Footnotes to work with it to begin with so I wouldn’t come without any WPForms experience? Whatever way I’m happy to assist, but waiting for your instructions here or at Gmail I need to get to speed testing Footnotes with the WPForms lite plugin available on WordPress.org.

    Best regards,
    @pewgeuges

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Thread Starter bogosavljev

    (@bogosavljev)

    Hi @pewgeuges,

    You can try with WPForms Lite in your environment, but I would like to provide you a temporary WP access so you can try on WPForms full version (you can create some dummy WPForms and test it). Thanks!

    Regards,
    Djuka

    • This reply was modified 5 years, 1 month ago by bogosavljev.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    @bogosavljev,

    Sadly what I can tell so far after testing WPForms lite—certainly building checkbox lists the exact same way the pro version does—is that using pointy bracketed footnote delimiters doesn’t work out as expected. The form labels are already plain text. Consistently when generating the value argument value of the input type="checkbox" element, the PHP strip_tags() or WordPress wp_strip_all_tags() functions would not be applied to the input string. Sorry for hinting such a non-starter, and for not looking into WPForms in the first place, but I already took such a long time responding.

    So I’ll definitely need to dig into the plugin’s code and try out a way to fix the issue from outside, as opposed to customizing the plugin and running into issues later when updating.

    There’s indeed a very good point in adding footnotes to checkbox labels in surveys about complex issues, like on your example page. The very nature of a checkbox label prevents authors from adding heaps of text, whereas participants may wish to have some extra information at hand. The ability to easily inform is even more important than the ability to easily style.

    I can’t promise anything but I’ll definitely research a fix.

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Thread Starter bogosavljev

    (@bogosavljev)

    @pewgeuges,

    OK, please don’t close this thread, and please inform me if you find a solution.
    I think it will be helpful, not just for me, but for all who are using WPForms.

    This can be a challenge for you 🙂

    Thanks,
    Djuka

    Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi @bogosavljev,

    Sorry for not seeing your response before writing and posting the above.

    try on WPForms full version (you can create some dummy WPForms and test it)

    That will indeed be very useful as the full version might have many more features everywhere, sorry for not thinking at the odds of this.

    We shall post a summary result here once done.

    Best regards,
    @pewgeuges

    Plugin Contributor pewgeuges

    (@pewgeuges)

    @bogosavljev,

    Sorry for not completing the job yet. The basic fix is ready and may be tested in v2.5.11d7 currently at https://downloads.wordpress.org/plugin/footnotes.zip. But there is a major concern regarding the Footnotes plugin, about incentivizing the addition of footnotes to form labels (and now removing them from the <‌input‌> element value attribute value), while not preventing clicks on footnote referrers from toggling input elements.

    The problem is that if visitors are immediately taken down to the footnote in the reference list, they may not notice that the checkbox status is toggled at the same time. In a worst-case scenario, the incorrect form is submitted in the wake. Anyway the process is screwed up and degrades the webform’s user experience, and probably even worse than that.

    To mitigate the adverse effect of clicking footnote referrers in labels of input elements, this v2.5.11d7 introduces an optional, configurable scroll down delay, in the hope that visitors will wonder about the unusual delay and have a chance to notice the change in the checkbox, and use the delay to click again to undo the change.

    Visitors already in the habits of double-clicking footnote referrers in form labels will keep being impacted by the scroll-down delay. To mitigate this downside in turn, v2.5.11d7 has also an option to enable asymmetric scroll durations, and separate settings for scroll-up duration (already existing, used for both ways by default) and scroll-down duration. E.g. scrolling down could be delayed by 800 ms and then take only 100 ms, while scrolling up would start immediately but the elevator would need 600 ms.

    However, scroll delays don’t work when hard links are enabled. As hard links make sure that footnote scrolling also works in browsers with JavaScript disabled, triggering an extra click to neutralize the effect on the checkbox status, of the click on the referrer, won’t work there either. I’ve been unable to implement this behavior with JavaScript enabled, though.

    The bottomline is that visitors without JavaScript enabled in their browser can feel tricked into checking boxes merely by clicking on footnote referrers. Visitors with JavaScript, on the other hand, may wonder about the Footnotes plugin coming with scroll animation and delays but not with the ability to make clicks on footnote referrers status neutral for checkboxes and other input elements usually toggled by clicking on their label.

    A “brute” solution would disconnect labels from input elements. That is even easier than removing footnotes from input element values. (It only takes a regex search-and-replace, no need for a do-while loop.) But that seems like pulling down user experience and compromising accessibility. Assistive technologies and the WCAG are making sure accessibility relies on the label, not the input value attribute, and while WPForms uses the label’s inner text for the input’s value so assistive technologies could rely on the value as well, that might not be true everywhere.

    For now I’m posting this here for the Community to have a chance to look into the issue and the preview of what Footnotes’ oncoming v2.6.0 may look like with an AMP compatibility mode. As this is not yet fully validated, and the traditional jQuery mode still has accessibility bugs, the fix for WPForms shall become available ASAP well ahead of 2.6.0, as an unreleased but tagged v2.5.11 with Stable Tag 2.5.10 because of the trouble caused by the recent 2.5.9d1 release accident.

    Will your client be satisfied with the current status as in v2.5.11d7 at https://downloads.wordpress.org/plugin/footnotes.zip? Or would it make sense to test an option disconnecting the labels from their input elements, in the hope that assistive technologies will use the value by lack of a label? Or would they find the label nevertheless when using surrounding text to describe the input element? And will visitors accept the constraint of needing to click or tap right on the checkbox in exchange of increased safety?

    Plugin Contributor pewgeuges

    (@pewgeuges)

    The above is unclear, sorry. WPForms does not support fancy input values; if a label is non-empty, it is escaped and used as the value. A footnote text is not expected to be part of the value, as little as it is part of the label. Therefore when footnotes are processed, they need to be deleted in the values. Currently that is done by this code; I’m not sure that the regex is good, so it’s posted here for review:

    
    $l_str_value_regex = '#(<input [^>]+?value=["\'][^>]+?)' . $l_str_start_tag_regex . '[^>]+?' . $l_str_end_tag_regex . '#';
    
    do {
    	$p_str_content = preg_replace( $l_str_value_regex, '$1', $p_str_content );
    } while ( preg_match( $l_str_value_regex, $p_str_content ) );
    

    To address the problem of the click event bubbling where clicking a footnote referrer toggles the input field, I’ve tried adding this code in the function called by the click event, but that does not work:

    
    jQuery( 'span' ).click( function( event ) {
    	event.stopPropagation();
    });
    

    But as already stated, that doesn’t help anyway when jQuery, or JavaScript overall, are disabled. Instead, I’m now trying to optionally disconnect from input elements those labels that have footnotes in them and will pose a safety threat, but this isn’t working either:

    
    preg_replace(
    	'#(<label [^>]+?for=["\'])(((?!</label>).)+' . $l_str_start_tag_regex . ')#g',
    	 '$1' . $l_str_disconnect . '$2',
    	 $p_str_content
    );
    

    Sorry for thinking (above) that that would be “easy”; it isn’t anything close to easy.

    I don’t know if such an option would be useful though, considering that making it harder to check a box may also be considered a nuisance.

    All these problems are part of the explanation why v2.5.11 is not ready yet.

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi @bogosavljev,

    The announced urgent bugfix v2.5.11 has just been committed and is now available for download from https://downloads.wordpress.org/plugin/footnotes.2.5.11.zip. As the Stable Tag remains 2.5.10, neither one-click update nor automatic update will work for this version. That is because v2.6.0 is not ready yet, and because of the release frequency concerns outlined above. But unlike initially envisaged when projecting to base v2.5.11 on v2.5.10, the full v2.6.0d7 with all the accessibility bug fixes implemented so far is now part of v2.5.11.

    Not available yet is the disconnecting option to optionally disconnect from input elements, those labels with footnotes so as to make it impossible that a click on a footnote referrer triggers a status change in the input element. This option, if it is really desirable and desired given it’s said to make those elements inaccesible to assistive technologies—we really need fresh tests to see if that is still true or it’s already been addressed—we’ll be eager to make it part of a v2.5.12, especially if v2.6.0 still isn’t complete by then.

    Should anything not meet your expectations or your clients’ requirements, be sure to keep in touch, following up in this topic or opening a new one, and we’ll be happy to assist you further.

    Thank you for triggering WPForms compatibility on Footnotes’ side!

    Thread Starter bogosavljev

    (@bogosavljev)

    Hi @pewgeuges,

    I have tried v2.5.11 and it’s working (no duplicate entries), scroll to Reference at the bottom in the footer widget area is working as well (but no smooth scroll).

    The only thing that is not working is the smooth scroll onclick function from the footnote and back from Reference to a footnote, and the jquery console error:

    OnClick from footnote to Reference:
    Uncaught Error: Syntax error, unrecognized expression: [name=r+11788+1+1]

    And OnClick from Reference to footnote:
    Uncaught ReferenceError: footnote_moveToAnchor_11788_1 is not defined

    Thanks,
    Djuka

    Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi Djuka,

    Thanks for your feedback and for reporting these bugs. The one with Uncaught ReferenceError: footnote_moveToAnchor_11788_1 is not defined is due to me adding a second scroll function for asymmmetric durations but missing out on syncing the plain JavaScript reference container script where I’ve only renamed the scroll function to the new footnote_moveToReference function because in plain JavaScript, scroll function is used and defined only for the purpose of expanding a default-collapsed container. Sorry that will be corrected.

    Smooth scrolling however is available only in jQuery script mode. To enable smooth scrolling, please open the dashboard under the General settings tab, and in the Reference container metabox, set Script mode to jQuery. That is what I tested for this version since the whole thing about scroll delays and durations in Footnotes depends on jQuery.

    I’m now unable to reproduce the Uncaught Error: Syntax error, unrecognized expression: [name=r+11788+1+1] as it doesn’t show up in console either jQuery mode or plain JS mode. To investigate further I’ll need much more time and eventually use different browsers too. Currently I’m using Chrome but have Firefox at hand that I also use often.

    Sorry for missing out on these bugs, that shall be fixed ASAP in v2.5.12. For the purpose it’d be helpful to know if you take issue with checkboxes being toggled when merely clicking footnote referrers in checkbox labels.

    Thank you!
    @pewgeuges

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    Hi @bogosavljev,

    A new unreleased bugfix version has now become available at https://downloads.wordpress.org/plugin/footnotes.2.5.12.zip

    This v2.5.12 addresses most if not all concerns. Above all it has now an option to enable the CSS-based smooth scrolling behavior that @paulgpetty advised in https://wordpress.org/support/topic/functionally-great/#post-13607795 months ago. Excuse-me please for not re-testing it sooner in response to your request and posting the related CSS style rule:

    
    html {
    	scroll-behavior: smooth;
    }
    

    This can now be enabled as internal CSS under the General settings tab > Scrolling behavior > CSS-based smooth scrolling. The new setting defaults to no because I noticed that it slightly disturbs Footnotes’ traditional jQuery-based scroll animation, so it cannot be enabled by default.

    The jQuery console errors:

    OnClick from footnote to Reference:

    
    Uncaught Error: Syntax error, unrecognized expression: [name=r+11788+1+1]
    

    The string [name=r+11788+1+1] does not exist in the document, where the string id="r+11788+1+1" is found instead.

    A similar bug in Hugo had been reported previously (datetime="2017-06-05") in the SemicolonWorld forum and got no response:

    https://www.semicolonworld.com/question/62640/hugo-markdown-footnotes-emitting-jquery-exception

    The same bug report was replicated later (2020-01-08) on Stack Overflow and got no response either, but the reporter subsequently shared a workaround:

    https://stackoverflow.com/questions/59652209/hugo-markdown-footnotes-emitting-jquery-exception

    Recently (one month ago), a similar jQuery exception error message (with an empty name) has been reported on Reddit as related to the Divi theme and got no comments either:

    https://www.reddit.com/r/divi/comments/lm38ro/uncaught_error_syntax_error_unrecognized/

    Generally these errors are being fixed by adding quotation marks around the name as in task item #11505 for Foswiki:

    https://foswiki.org/Tasks/Item11505

    I don’t know what we can do in the Footnotes plugin for WordPress but as a rule of thumb, one step would involve switching theme to see if the error message persists. On my end I don’t see it.

    OnClick from Reference to footnote:

    
    Uncaught ReferenceError: footnote_moveToAnchor_11788_1 is not defined
    

    Apologies again for this error. It’s now fixed, along with many other errors as listed in the 2.5.12 changelog.

    Should anything not meet your and your clients’ expectations as well as for any bugs please keep in touch, a v2.5.13 shall be made available as soon as needed if v2.6.0 is not fully debugged for release by then.

    Thank you for contributing to fix the Footnotes plugin!

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges.
    Plugin Contributor pewgeuges

    (@pewgeuges)

    Short form:

    There are 2 ways to get a WPForms up and running now:

    1. Plain JavaScript and CSS: Set script mode to plain JavaScript in the Reference container metabox, and enable CSS smooth scroll in the Scrolling behavior metabox. Then hard links are enabled, that do prevent clicks on footnote referrers from toggling checkboxes, in Chrome like for any hyperlinks in checkbox labels.

    2. jQuery: Set script mode to jQuery in the Reference container metabox, and disable CSS smooth scroll in the Scrolling behavior metabox. Then soft links are enabled, that do NOT prevent clicks on footnote referrers from toggling checkboxes. To prevent this, please set the new Solve input label issue select box to option ‘A. Footnotes are moved out and appended after the label’s end (recommended)’, in the new Referrers in labels metabox under the Referrers and tooltips tab.

    As stated in the descriptions currently found around this new setting:

    Clicking a footnote referrer in an input element label toggles the input except when hard links are enabled. In jQuery mode, the recommended solution is to move footnotes and append them after the label (option A).

    And Option B is discouraged because disconnecting a label from its input element may compromise accessibility. This option is a last resort in case footnotes must absolutely stay inside the label. (Using jQuery ‘event.stopPropagation’ failed.)

    This follow-up is also meant to correct what I posted above while not yet holding the solution that cuts the footnotes in the labels and pastes them after the label. On the survey form you shared for this support topic, this has almost no impact; only the font size is slightly smaller, but that can be corrected by styling the span.moved_footnote class.

    I’ve also looked into the (minified reformatted) jQuery and custom.unified.js libraries. The expression '[name=' + this.hash.slice(1) + ']' comes from the latter, listed last in the console. This library is not needed for footnotes (it contains e.g. more for smooth scroll and WooCommerce) and can be disabled so the error disappears, and only the (preexisting) Uncaught TypeError: s.event.addProp is not a function error remains.

    Consistently, in a page using GeneratePress for example, clicking the test footnote referrer in the exact same form as well as clicking the test backlink in the exact same reference container in the footer (copy-pasted from a backup copy) does not produce any console error.

    I’m sorry that you are having this issue, and I don’t see any easy way out. But hopefully the fixes implemented and available since v2.5.12 do enable your client to get the survey up and running on due date. If not, or should you encounter any similar or other issues using the Footnotes plugin, please feel free to post in this thread or open a new one and we’ll strive to assist and bring solutions.

    Best regards.
    @pewgeuges

    Plugin Contributor pewgeuges

    (@pewgeuges)

    As this might be of use for all users of Divi theme using Footnotes, we’ll share the fix here:

    Fixing the Syntax error, unrecognized expression with a footnote fragment ID or a referrer anchor takes adding a pair of single quotes around the string "+this.hash.slice(1)+" in wp-content/themes/Divi/js/custom.unified.js so that:

    
    (d=t("[name="+this.hash.slice(1)+"]"))
    

    becomes:

    
    (d=t("[name='"+this.hash.slice(1)+"']"))
    

    As of the Uncaught TypeError: s.event.addProp is not a function, it only occurs occasionally. After fixing the above I’m able to click back and forth without any console output.

    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges.
    • This reply was modified 5 years, 1 month ago by pewgeuges. Reason: Uncaught TypeError: s.event.addProp is not a function
    • This reply was modified 5 years, 1 month ago by pewgeuges.
Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Compatibility issue with WPForms?’ is closed to new replies.