Skip to:
Content

bbPress.org

Opened 3 years ago

Closed 2 years ago

Last modified 20 months ago

#3327 closed defect (bug) (fixed)

BUG: Threaded replies not working if WordPress adminbar is disabled

Reported by: robin-w's profile Robin W Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6.7 Priority: normal
Severity: normal Version:
Component: Component - Replies Keywords:
Cc:

Description

Reported in bbpress support

https://bbpress.org/forums/topic/bug-threaded-replies-not-working-if-wordpress-adminbar-is-disabled/

In bbpress 2.6.3 threaded replies only work if the WordPress adminbar is enabled. If it is disabled and you click a reply link of a lower level reply the page is reloaded which is not supposed happen. If you then post the reply, it is added at the end of the forum post and not after the corresponding reply.
The bug is in templates/js/reply.js line 109ff. If you remove the reference to the adminbar, threaded replies work properly.
The bug did not exist in bbpress 2.6.1.

Change History (7)

#1 @mjonesnerdery
3 years ago

templates/default/js/reply.js

Line 110:
if ( typeof ( adminbar ) !== 'undefined' ) {

should probably just be:
if ( adminbar ) {

Since document.getElementById() returns null if the ID is not found, and in JS, the typeof(null) is "object" not "undefined".

#2 @AndyHenderson
3 years ago

I see the same error. Note the reply appears at the end of the topic because the JS error does not prevent the default action of the reply 'button' (actually a formatted a tag) which refreshes the page with the reply box at the bottom.

The following work-around works because it prevents the default action of the reply 'button':

// Prevent reply button in forums from executing a refresh of the page
add_filter('bbp_get_reply_to_link', 'ctcFixReplyToLink', 10, 3);
  function ctcFixReplyToLink( $link, $r, $args ) {
    return str_ireplace( '"return addReply', '"event.preventDefault(); return addReply', $link );
  }

#3 @johnjamesjacoby
2 years ago

  • Component changed from General to Component - Replies
  • Milestone changed from Awaiting Review to 2.6.7
  • Owner set to johnjamesjacoby
  • Status changed from new to accepted

#4 @johnjamesjacoby
2 years ago

In 7173:

Replies: fix hierarchical replies not scrolling to the new form location when admin toolbar is hidden.

This commit checks that the adminbar variable is not empty before also making sure that it is not undefined, as it's possible for it to also simply be null when the toolbar is hidden.

In trunk for 2.7.0. See #3327.

Props mjonesnerdery.

#5 @johnjamesjacoby
2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 7174:

Replies: fix hierarchical replies not scrolling to the new form location when admin toolbar is hidden.

This commit checks that the adminbar variable is not empty before also making sure that it is not undefined, as it's possible for it to also simply be null when the toolbar is hidden.

In branches/2.6 for 2.6.7. Fixes #3327.

Props mjonesnerdery.

#6 @johnjamesjacoby
2 years ago

#3364 was marked as a duplicate.

#7 @johnjamesjacoby
20 months ago

#3441 was marked as a duplicate.

Note: See TracTickets for help on using tickets.