WordPress.org

Making WordPress.org

Opened 6 years ago

Closed 6 years ago

#186 closed defect (fixed)

"request" keyword is added multiple times

Reported by: SergeyBiryukov Owned by: coffee2code
Milestone: Priority: normal
Component: Make (Get Involved) / P2 Keywords:
Cc:

Description

On the Polyglots blog, if you click "request" several times in a row, the keyword is appended multiple times, which looks weird (see the screenshot).

This is the click handler:

$('.p2-request-tag').click( function() {
	var tags = $('#tags'), val = tags.val();
	if ( val === 'Tag it' )
		tags.val( 'request, ');
	else
		tags.val( 'request, ' + val );
});

I don't see it anywhere in the open sourced code, but this should fix it:

$('.p2-request-tag').click( function() {
	var tags = $('#tags'), val = tags.val();
	if ( val === 'Tag it' )
		tags.val( 'request, ');
	else if ( 'request,' != val.substr( 0, 8 ) )
		tags.val( 'request, ' + val );
});

Attachments (1)

meta-186.png (17.7 KB) - added by SergeyBiryukov 6 years ago.

Download all attachments as: .zip

Change History (3)

#1 @coffee2code
6 years ago

  • Owner set to coffee2code
  • Status changed from new to accepted

#2 @coffee2code
6 years ago

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

Fixed.

I opted to use val.indexOf( 'request' ) < 0 instead of 'request,' != val.substr( 0, 8 ) as the conditional check before adding 'request' into the tags field so that if the tag appears anywhere (instead of just the beginning) then it won't be added via the helper link.

Note: See TracTickets for help on using tickets.