Making WordPress.org

Changeset 11570


Ignore:
Timestamp:
02/17/2022 07:14:23 AM (4 years ago)
Author:
dd32
Message:

Trac: Reorganise how the click handler for the component suggestion works, sometimes the click handler wouldn't register that the component had been clicked.

See #6078.

Location:
sites/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site.html

    r11565 r11570  
    55
    66<?python
    7         scripts_version = '162'
     7        scripts_version = '163'
    88        project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0]
    99        wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/'
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r11544 r11570  
    19871987                                if ( ! noticeDiv ) {
    19881988                                        noticeDiv = $( '<div id="componentSuggest"/>' ).insertBefore( $( '.buttons').first() );
     1989
     1990                                        noticeDiv.on( 'click', 'a.component', function(e) {
     1991                                                e.preventDefault();
     1992                                                const component = $(this).text();
     1993
     1994                                                $( `#field-component option[value="${component}"]` ).prop( 'selected', 'selected' ).change();
     1995                                        } );
    19891996                                }
    19901997                                noticeDiv.html( getNoticeHTML( matchingComponents ) );
     
    20042011
    20052012                                if ( hasMatches ) {
    2006                                         template.append( $('<ul/>' ) );
    2007                                         ulList = template.find('ul');
    2008 
    2009                                         ulList.on( 'click', 'a', function(e) {
    2010                                                 e.preventDefault();
    2011                                                 const component = $(this).text();
    2012 
    2013                                                 $( `#field-component option[value="${component}"]` ).prop( 'selected', 'selected' ).change();
     2013                                        ulList = $('<ul/>' );
     2014
     2015                                        matchingComponents.forEach( (component) => {
     2016                                                ulList.append( $( `<li><a href="#" class="component">${component}</a></li>` ) );
    20142017                                        } );
    2015 
    2016                                         matchingComponents.forEach( (component) => {
    2017                                                 ulList.append( $( `<li><a href="#">${component}</a></li>` ) );
    2018                                         } );
     2018                                        template.append( ulList );
    20192019                                }
    20202020
Note: See TracChangeset for help on using the changeset viewer.