Support Forum

Reply button not properly setting anchor and showing the editor form

SS Sebastian Schimpf
Sebastian Schimpf
Member

Hi there,

my client just reported that he clicks on the reply button but nothing happens. 

I did some testing and I found that sometimes if I click too quickly onto the “reply” button, there is an “accumulation” of the anchor tags in the URL:

#spEditFormAnchor#spEditFormAnchor#spEditFormAnchor#spEditFormAnchor

… and nothing happens. 

Is there any way to prevent this?
I found that the anchor is not fully reliable. This is such a vital feature. I want to make sure that people always see the editor to write a reply when they click this button. 

What do you suggest to make this more “dummy proof”?

21 Answers

New Answer

MP Mr Papa
Mr Papa
Member

It took some real finagling to make this happen…  it was hard to hit the button fast enough…  but I could see what you were saying because the same happens once the reply form is opened…  the anchor fragment gets added… in this case, it doesnt affect anything because you can still save…

but it tells me enough of what is going on, I think…  the reply button onclick handler probably needs cleaning up after first action…  will investigate…

*update…  was able to occasionally get it to happen…  and is consistent with my above… users will have to work hard to see this, but certainly possible… 

MP Mr Papa
Mr Papa
Member

so have a fix…  not an easy way to get it to you though… if you are comfortable editing some js code, you can do this:

First, open up your wp-config.php file and add this line of code:

define(‘SP_SCRIPTS_DEBUG’, true);

that will let you edit the dev scripts instead of the compressed ones…

then find file simple-press/forum/resources/jscript/sp-forum-dev.js and edit it…  around line 146, you find this code:

jQuery('#'+editorId).slideDown();
jQuery('#'+editorId).slideDown(); 
location.href = location.href + '#spEditFormAnchor'; 
spjEdOpenEditor(formType);

and then change it to:

jQuery('#'+editorId).slideDown(); 
jQuery('#'+editorId).slideDown(); 
if (!window.location.hash) location.href = location.href + '#spEditFormAnchor'; 
spjEdOpenEditor(formType);

and you should be good to go…

SS Sebastian Schimpf
Sebastian Schimpf
Member

Hi Mr Papa, 

thanks for figuring this out. 

You may want to consider that loading time plays a vital role in the possible occurrence of the non-functional buttons. If the editor is not fully loaded, it may happen much more easily that the anchor fragment gets added and the reply button is rendered nonfunctional. 
But to be honest, I don’t understand enough about the whole structure to verify this. 

Will your code change be implemented in the next SP updates?

SS Sebastian Schimpf
Sebastian Schimpf
Member

I have also noticed that in case I click the reply button and scroll up to the top of the page, the next click on the button does not take me down to the message editor anymore. 
I think the interface could be coded a bit more with such things in mind. 

When I remove the #spEditFormAnchor manually from the URL in the browser address bar and I click on the reply button again, it adds “#spEditFormAnchor#spEditFormAnchor” … and if I do it again, it will add the anchor 3 times. I think it would make sense if you change the coding and make sure the button works in any case and always triggers the jump to the form. 

Does that make sense?

Edit: The funny thing is that it works on the new topic form. 
Here I can scroll up and click again and the anchor jump works, even though the URL shows the anchor many times already:
/?new=topic#spEditFormAnchor#spEditFormAnchor#spEditFormAnchor

I don’t understand this

MP Mr Papa
Mr Papa
Member

hmm… I cannot replicate the hash fragments growing anymore at all…

did you go to forum – toolbox – housekeeping and clear the combined js cache?  and also, I would clear the browser cache too since they hang on to dear life to cache js and css…

I can check and see – probably not too hard to make the add reply scroll to the form – as you say we do that already on the new topic…

yes, all these changes will be in the forthcoming 5.8 release…  we are probably a month or two away from that though…

SS Sebastian Schimpf
Sebastian Schimpf
Member

Hi Mr Papa,

I have made the changes to the JS file after changing the wp-config.php. 

Am I supposed to change it back when I uploaded the updated JS? 

I did that. 

I have also cleared the cache, of which I had no idea before you mentioned it. 

I am still facing the issue. 

https://www.biodynamicbreath.com/breathwork-practitioner-forum/bbtri-announcements/our-newest-mebers-in-the-practitioner-database/

You can easily test it by scrolling up again after clicking the reply button and just click onto it again. 

How can I find out if the script is actually properly updated on the server?

I found this sp-forum.js but when I open it from the forum source code it is decoded, so I can’t really find my updated code. Sorry but this is a bit beyond my knowledge. 

YS Yellow Swordfish
Yellow Swordfish
Member

No – you need to leave the script switch in the wp-config file as instructed. This ensures that the system uses the non-minimised script files. So turn it back on and then again – clear the js cache.

When the next update comes along you can remove the switch so that the plugin again uses the minimised scripts.

SS Sebastian Schimpf
Sebastian Schimpf
Member

So I did just that but with the same result!
Changed the wp-config, cleared all caches … still the same. 

What am I doing wrong?

SS Sebastian Schimpf
Sebastian Schimpf
Member

Just tested in IE to see if it may just be a Chrome issue. 
The accumulation of anchor tags still happens. At least IE is jumping to the anchor even though it is multiplied in the url after clicking several times. 

I can’t see that anything changed in the way it functions after making the change to the JS. 

 

And actually i should see this script being used, right:sp-forum-dev.js

but it is still sp-forum.js

YS Yellow Swordfish
Yellow Swordfish
Member

I don’t really have any way of knowing if you have dome something wrong. Give me a detailed step-by-step description of what you are seeing and I will see if I can replicate. I certainly can not based on what you have described previous to the change.

SS Sebastian Schimpf
Sebastian Schimpf
Member

Thanks Andy, but this is way to complicated for me right now. 
I did exactly what you suggested and it did not work. 
I also don’t like the fact that the forums scripts are not compressed anymore after making this change. Our site is not the fastest, this will add even more weight to it. 

I am out. I need to find a better solution for this issue or ignore it for now. 

SS Sebastian Schimpf
Sebastian Schimpf
Member

Could you possibly sent me the compressed JS file with the change in it, so I may just replace the one on our server?
Maybe that will work. 

sebastian.schimpf {at} gmail.com

YS Yellow Swordfish
Yellow Swordfish
Member

We can see if that is possible. There are a lot of changes to all of our JavaScript files for 5.8 so it would need to be hand-crafted. I will try and take a look later today.

SS Sebastian Schimpf
Sebastian Schimpf
Member

okay … please see what you can do. 

Thanks!