Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-56157

<liferay-ui:icon /> tag generates HTML id containing "dot" when its message contains it (prevents url to be opened in dialog)

    Details

      Description

      When you have a JSP markup like this:

      <liferay-ui:icon-menu showWhenSingleIcon="<%= true %>">
      	<portlet:renderURL var="editEngagementURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>" />
      
      	<liferay-ui:icon
      		image="edit"
      		message="edit-engagement.short"
      		method="get"
      		url="${editEngagementURL}"
      		useDialog="<%= true %>"
      	/>
      </liferay-ui:icon-menu>
      

      Then in the generated HTML, when you click on the icon in the menu, the URL will not be opened in dialog, but in browser window as regular link. The reason is the "." in the message attribute. com.liferay.taglib.ui.IconTag uses the message to generate its id for the icon's HTML element (when id is not set, as in my example), but does not escape the dot.

      Example of generated id is: _1_WAR_lgspengagementsportlet_dhec_column1_0_menu_edit-engagement.short

      Then when the id is used at the bottom of /portal-web/docroot/html/taglib/ui/icon/page.jsp inside Liferay.Icon.Register, this module will fail to register the dialog, since it uses this code:

      register: function(config) {
      	...
      	var icon = A.one('#' + config.id);
      	...
      	if (icon) {
      	...
      	}
      

      Given CSS selector A.one('#_1_WAR_lgspengagementsportlet_dhec_column1_0_menu_edit-engagement.short' will not find the icon element in the DOM, since the '.short' part of the id will be interpreted as CSS class selector on element '#_1_WAR_lgspengagementsportlet_dhec_column1_0_menu_edit-engagement'.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                haoliang.wu Haoliang Wu (Inactive)
                Reporter:
                josef.sustacek Josef Šustáček
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 25 weeks, 5 days ago

                  Packages

                  Version Package
                  6.2.X EE
                  7.0.1 CE GA2