Dnn.Platform icon indicating copy to clipboard operation
Dnn.Platform copied to clipboard

[Bug]: "Open Link In New Window" is enforced on "Standard" pages

Open DanielBolef opened this issue 7 months ago • 9 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

What happened?

If a non-"Standard" type page with "Open Link In New Window" enabled is switched to type "Standard", the menu link still opens in a new tab/window. This is especially problematic when the page is disabled, as it will open a new tab/window to nowhere.

Steps to reproduce?

  1. Create a page with a type other than Standard (ie. URL)
  2. Enable "Open Link In New Window"
  3. Switch the page type to "Standard"
  4. (Optional, to demonstrate the more problematic case) Switch "Disable Page" to enabled (Advanced -> More)
  5. Make sure "Display in Menu" is enabled (it is by default)
  6. Save
  7. Refresh; click the menu link to that page

Current Behavior

Page opens in new tab/window, or new tab/window to nowhere opens if disabled

Expected Behavior

Page should open in current window, or if disabled, do nothing.

Another way to resolve this would be to show the "Open Link In New Window" option for "Standard" pages. The other three page types already show it, and it could be a valid option for "Standard" pages as well. If the page is disabled however, this option should do nothing. This solution would stay closer to existing behavior. It's likely there are site admins out there aware of this issue and using it to their advantage.

Relevant log output


Anything else?

Tested/occurring in v9.13.9 in addition to v10.0.1.

Affected Versions

10.0.1 (latest v10 release)

What browsers are you seeing the problem on?

Chrome

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

DanielBolef avatar May 21 '25 21:05 DanielBolef

Opening a navigation link in the current or new window is almost always implemented in the theme. So, it's pretty important you let us know, for the page you are on, what theme is assigned?

jeremy-farrance avatar May 21 '25 23:05 jeremy-farrance

I don't think the theme is a factor in this case. However, on my clean 10.0.1 install I used to replicate the issue, I'm using the Aperture theme with the default layout. I observed the same behavior as on my real site, which is using a custom theme.

DanielBolef avatar May 22 '25 11:05 DanielBolef

I think the correct resolution to this issue is to add the Open Link In New Window toggle to the page for Standard pages. However, there is not, to my eye, a clean place to add it. If we can figure out where it should go, adding the toggle is simple.

Here's an example of it added to the bottom of that section:

screenshot of page edit screen with Open Link in New Window toggle added to the bottom

Any thoughts @david-poindexter?

bdukes avatar May 27 '25 21:05 bdukes

I am pretty sure only the ddr-menu template for the theme needs to be updated to use that value. But looking at https://github.com/dnnsoftware/Dnn.Platform/blob/4f20ac1a0cdd3fa21078467e4d7af11b905df6d7/DNN%20Platform/Skins/Aperture/menus/desktop/RazorMenu.cshtml#L16-L35 it appears to already be using the page Target so maybe we have a bug downstream from that...

valadas avatar May 28 '25 05:05 valadas

Oh, if I am not mistaken it is just missing target= before @attrTarget

valadas avatar May 28 '25 05:05 valadas

@valadas, that appears to be handled on line 19.

@bdukes, the only real problem I see is that in the (unusual edge) case where both page.Target is "_blank" and page.Enabled is false, the code snippet above shows that a Link-Disabled page will still have href="javascript:void(0);" target="_blank" which pops open a new tab (with a URL in Chrome of "about:blank").

So the more-correct fix would be to have the PersonaBar Pages handle the case, on-save, to ensure that a page type=standard has target="".

However, though not an obvious case the theme developer would think-through (I certainly never thought of it before), it can also be solved in the theme. Simply change line 19 (Aperture RazorMenu.cshtml) to:

var attrTarget = ( !string.IsNullOrEmpty(page.Target) && page.Enabled ) 
  ? ("target=\"" + page.Target + "\"") 
  : string.Empty
;

In English, only add the target if the page is Link-Enabled AND page.Target is not empty.

Additional Thoughts

  1. In the PersonaBar Pages extension, for a Page's settings, Advanced / MORE... I think the label needs to be changed from "Disable Page" to "Disable Page Link" to be more obvious as to what it does. And probably improve the (i) text to better explain what this setting does. I've certainly had to explain it many times to clients and staff who thought it "disabled the page" and then argued with me about what that meant and what the expect results "should be."

  2. I could be mistaken about this, but I think most (accessibility-)correct thing to do is when page.Enabled is false, is to switch and output a disabled button instead of an <a>.

jeremy-farrance avatar May 28 '25 16:05 jeremy-farrance

I don't think this issue is about menu templates. The problem is that the "Open Link in New Window" toggle is not visible when Page Type is set to Standard. So there's not a visible way to adjust that setting if you convert from a URL page to a Standard page.

bdukes avatar May 29 '25 13:05 bdukes

Oh I see

valadas avatar May 29 '25 17:05 valadas

I don't think this issue is about menu templates. The problem is that the "Open Link in New Window" toggle is not visible when Page Type is set to Standard. So there's not a visible way to adjust that setting if you convert from a URL page to a Standard page.

Agreed, but that fix requires waiting for a change to DNN and then upgrading to a new release. That could be weeks and sometimes can take months/years. I provided a solution that works right now if @DanielBolef is comfortable editing the Aperture skin files.

In addition, Aperture needs to be a solid reference for theme developers on how to do things correctly and better. So, since you've made me realize this is the wrong place to leave these notes (above), I'll open a new issue so that my notes stay in a more useful place going forward. Thanks!

jeremy-farrance avatar May 29 '25 19:05 jeremy-farrance