Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

#8430 closed defect (bug) (fixed)

Adding a new subnav item in Nouveau messages breaks nouveau js

Reported by: venutius's profile Venutius Owned by: imath's profile imath
Milestone: 8.0.0 Priority: normal
Severity: normal Version: 3.0.0
Component: Templates Keywords: has-patch commit
Cc:

Description

With Nouveau the provide messages functions changes so that the subnav items - compose, starred etc. load via js.

The problem comes when one wishes to add a new subnav item to the messages screen, if you use the traditional method the js for the other subnav breaks - underscores reporting that 'i' is not defined.

When I say the traditional method, I means as per the following:

class BP_Message_Archive_Component extends BP_Component {
    function setup_nav($main_nav = array(), $sub_nav = array()) {
        bp_core_new_subnav_item( array(
	    'name'              => 'Archive',
	    'slug'              => 'archive',
	    'parent_url'        => trailingslashit( $user_domain . 'messages' ),
	    'parent_slug'       => 'messages',
	    'screen_function'   => 'messages_profile_archive',
	    'position'          => 25,
	    'item_css_id'       => 'member-messages-archive'
            )
        );
    }
 
    function setup_admin_bar() { 
         $wp_admin_nav[] = array(
		'parent' => 'my-account-messages',
		'id'     => 'my-account-messages-archive',
		'title'  => 'Archive',
		'href'   => trailingslashit( $item_link ) . 'archive');
         parent::setup_admin_bar( $wp_admin_nav );
    }
}

function messages_profile_archive() {
	add_action( 'bp_template_content', 'messages_profile_archive_screen' );
	bp_core_load_template( 'members/single/plugins' );
}

function messages_profile_archive_screen() {
	bp_get_template_part('members/single/profile-messages-archive');
}

// The template profile-messages-archive.php simply contains <div><p>Hello</p></div>

This method works fine with BP Legacy, however with Nouveau if you select the messages archive link from the admin bar, it takes you to the correct page, the template message displays and you are placed in the profile>>messages>>archive page. However clicking on any of the other messages subnav items fails, giving a js error as mentioned above.

Is there some secret sauce to preventing this error?

Attachments (1)

8430.patch (2.2 KB) - added by imath 4 years ago.

Download all attachments as: .zip

Change History (5)

#1 @imath
4 years ago

  • Milestone changed from Awaiting Contributions to 8.0.0

Good question, I need to refresh my memory about it. But at the minimum we should provide guidance to do so using JavaScript. I'm going to look at it during 8.0.0. Thanks for reporting this 👍

#2 @imath
4 years ago

  • Owner set to imath
  • Status changed from new to assigned

@imath
4 years ago

#3 @imath
4 years ago

  • Keywords has-patch commit added
  • Version changed from 7.1.0 to 3.0.0

8430.patch is making sure only supported Backbone views are handled in JavaScript. In case of an unknown view like one screen added by a plugin, it simply loads the page location.

#4 @imath
4 years ago

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

In 12941:

Nouveau: only handle Messages supported views with the Backbone router

When an unsupported view is generated by a plugin (eg: adding a new Messages Component sub nav item), it is skipped by the Backbone router and the link attached to it is loaded the traditional way on click. If the current screen has been added by a plugin, the sub nav click handler also leaves the event loads the page traditionally.

Props Venutius

Fixes #8430

Note: See TracTickets for help on using tickets.