Jump to content

Javascript trigger for shareComment not updated


Go to solution Solved by bfarber,

Recommended Posts

Posted (edited)

I submitted this as feedback last week, but it looks to be a bug. In any case you currently have javascript related to this behaviour that doesn't do anything in your default theme. 

In version 4.4, this was the HTML for the share link on posts in html/forums/front/topics/post.phtml

{{if $comment->mapped('first') }}
	<li><a class='ipsType_blendLinks' href='{$comment->item()->url()}' data-ipsTooltip title='{lang="share_this_post"}' data-ipsMenu data-ipsMenu-closeOnClick='false' id='elSharePost_{$comment->$idField}' data-role='shareComment'><i class='fa fa-share-alt'></i></a></li>
{{else}}
	<li><a class='ipsType_blendLinks' href='{$comment->item()->url()->setQueryString( array( 'do' => 'findComment', 'comment' => $comment->$idField ) )}' data-ipsTooltip title='{lang="share_this_post"}' data-ipsMenu data-ipsMenu-closeOnClick='false' id='elSharePost_{$comment->$idField}' data-role='shareComment'><i class='fa fa-share-alt'></i></a></li>
{{endif}}

In version 4.5, you changed it to: 

{{if $comment->mapped('first') }}
	<li class='ipsMenu_item'><a href='{$comment->item()->url()}' title='{lang="share_this_post"}' data-ipsDialog data-ipsDialog-size='narrow' data-ipsDialog-content='#elSharePost_{$comment->$idField}_menu' data-ipsDialog-title="{lang="share_this_post"}" d='elSharePost_{$comment->$idField}' data-role='shareComment'>{lang="share"}</a></li>
{{else}}
	<li class='ipsMenu_item'><a href='{$comment->item()->url()->setQueryString( array( 'do' => 'findComment', 'comment' => $comment->$idField ) )}' title='{lang="share_this_post"}' data-ipsDialog data-ipsDialog-size='narrow' data-ipsDialog-content='#elSharePost_{$comment->$idField}_menu' data-ipsDialog-title="{lang="share_this_post"}" id='elSharePost_{$comment->$idField}' data-role='shareComment'>{lang="share"}</a></li>
{{endif}}

 

The notable change here is that you changed it from using data-ipsMenu to data-ipsDialog.

In both version 4.4 and 4.5 you have the following javascript related to this share link on /dev/js/front/controllers/core/ips.core.comment.js inside the javascript code for the core.front.core.comment controller.

this.on( 'menuOpened', '[data-role="shareComment"]', this.shareCommentMenu );

And further down: 

		/**
		 * User has clicked the share button within the comment; we'll select the text to make it easy to copy
		 *	
		 * @param 		{event} 	e 		Event object
		 * @param 		{object} 	data	Event data object
		 * @returns 	{void}
		 */
		shareCommentMenu: function (e, data) {
			if( data.menu ){
				data.menu.find('input[type="text"]').get(0).select();
			}
		},

 

I'm not sure what the fix would be here, as you don't seem to have a dialogOpened event and the click event would happen too early / not contain the information it needs to select the text.

This is the fix, in the javascript, change the event initialization to:

			this.on( 'openDialog', '[data-role="shareComment"]', this.shareCommentMenu );

And then change the method shareCommentMenu to: 

		shareCommentMenu: function (e, data) {
			if( data.dialog ){
				data.dialog.find('input[type="text"]').get(0).select();
			}
		},

(You may also want to rename the method from shareCommentMenu to shareCommentDialog)

Edited by TSP
  • 1 month later...
Posted
On 12/1/2020 at 3:33 PM, bfarber said:

I've logged a bug report to have this checked into, thanks.

 Btw, super minor, but also notice in the if

data-ipsDialog-title="{lang="share_this_post"}" d='elSharePost_{$comment->$idField}'

should be id=, instead of d=

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...