akeeba / engage

Akeeba Engage - Comments for Joomla!™ articles made easy
GNU General Public License v3.0
16 stars 10 forks source link

Multiple notifications #288

Closed jjnxpct closed 10 months ago

jjnxpct commented 10 months ago

Steps to reproduce the issue

In some cases a user impatiently pressed the comment button again (and again) because they do not see something is happening in the background. Resulting in multilple instances of the comment under the article.

We have tried this ourselfs with caching on and off. In both cases we are able to submit a comment multiple times.

I should be made impossible to hit the submit button while te previous sumbimt is being processed? Maybe showin a progress icon or something?

Also when we tried hitting the submit button multipal times we get an error regarding 'to many redirects'.

nikosdion commented 10 months ago

What was described is exactly how submitting a web form works, and has worked since the invention of web forms circa 1995.

Adding a JavaScript handler to prevent a user from submitting the form twice is outside the scope of this software. You can always do that with custom code, loaded in a template override.

nikosdion commented 10 months ago

I forgot to explain why it's outside the scope. Please let me do that, since that's important context.

Engage is designed to gracefully degrade when JavaScript is disabled. If JavaScript is disabled, you get a plain old textbox where you can type HTML. The comment button submits an HTML form which is validated and parsed on the server side. Therefore, even if you have JavaScript disabled (or, more likely, use something like NoScript) you can still submit comments.

Doing what you are asking requires making the submit button rely on JavaScript. Its type would be changed from submit to button and it would only work through a JavaScript handler. This would mean that the comment form would no longer degrade gracefully, which is in violation of the intended design principle.

This is why you need to do this yourself, in an override. I do not wish to have an option for something like that as it would require me implement something contrary to one of the design principles of the software. The purpose of overrides is that you can do that, even though I do not want to do it myself.

jjnxpct commented 10 months ago

Thanks for getting back to me on this Nicholas. I have to say I don't really understand what you are saying. But I do understand that we can only solve our issue by creating an override for the form and add some javascript to it. I will look into that.

Regardless of the technical stuff, our client gets multiple identical comments and notification. This annoys the users of the website and also my clients. So I need to 'fix' this. If adding javasxcript will do that, so be it. In the end I care more about the user experience of my clients then about the design principle I guess.

jjnxpct commented 10 months ago

I had to figure out how to do this, but I managed to add some jQuery script to change the button to 'button' and change the text to 'Wait...' an make it disabled and submit the form. So this way nog override is needed. Works OK for me. I just wanted to post this here in case anyone was interested. I also added an class to style the 'wait' text.

When scripting is disabled this will not be loaded and the default code of the comment form will be used. So it will still submit content. But when scripting is disabled a lot of other functions will also not work.

nikosdion commented 10 months ago

You have made a very good point. The JavaScript can be written in such a way that when it's disabled the comment form can indeed degrade to a regular HTML form. I had not thought of that. I have now implemented this feature like that.