Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hidden content objects to be used in navigation #68

Closed
swashbuck opened this issue Jun 17, 2024 · 4 comments · Fixed by #70
Closed

Allow hidden content objects to be used in navigation #68

swashbuck opened this issue Jun 17, 2024 · 4 comments · Fixed by #70
Assignees
Labels
enhancement New feature or request released

Comments

@swashbuck
Copy link
Contributor

swashbuck commented Jun 17, 2024

Subject of the issue

Currently, content objects that use "_isHidden": true behave similarly to topics that are locked in that they are grayed out and unclickable. The difference is that you can never navigate to a hidden content object, even when using its _id for the _customRouteId value.

In a use case that came up today, the course has a start page that's hidden from the menu. However, the client or designer (not sure which) wanted to be able to navigate to this page via the Previous button. The _customRouteId value for the Previous button is set to the start page's _id, but the button always appears disabled.

I understand excluding "_isAvailable": false content objects from Page Nav, as they aren't meant to be viewed at all. _isHidden just controls the content object's appearance on menus, though.

@swashbuck swashbuck added the enhancement New feature or request label Jun 17, 2024
@oliverfoster
Copy link
Member

oliverfoster commented Jun 18, 2024

_isHidden is not _isHiddenOnMenus

pageNav should naturally remove these content objects from normal next/back.

pageNav should behave as expected if a button is manually set on _customRouteId when routong to a hidden contentobject, i.e. not be greyed out unless locked

@swashbuck
Copy link
Contributor Author

pageNav should behave as expect if a button is manually set on _customRouteId to route to a hidden contentobject, i.e. not be greyed out unless locked, etc.

@oliverfoster Ok, so you're saying the functionality of _customRouteId should be amended to allow for content objects that use _isHidden: true to be navigated to? No other changes to the Page Nav functionality?

@oliverfoster
Copy link
Member

oliverfoster commented Jun 18, 2024

This is code in pageNav that looks at _isHidden. It forces the button to be visually disabled and behaviourally disabled and the tooltip to be hidden. I think both of those things should be removed and that _isHidden should be handled differently to make it more consistent with its intended behaviour.

The _customRouteId value should definitively override the model of the relevant button if defined.

Instead of:

// Get models, skipping any undefined types (ex. deprecated button types)
let buttonModel = buttonTypeModels[type];
if (!buttonModel) continue;
// Find buttonModel from config._customRouteId if not found in defined type
if (buttonConfig._customRouteId) {
buttonModel = data.findById(buttonConfig._customRouteId);
}

Do this:

      // Get models, skipping any undefined types (ex. deprecated button types)
      // Find buttonModel from config._customRouteId if not found in defined type
      let buttonModel = buttonConfig._customRouteId
        ? data.findById(buttonConfig._customRouteId)
        : buttonTypeModels[type];
      
      if (!buttonModel) continue;

And getPrevPage and getNextPage should exclude _isHidden pages as they do !_isAvailable pages:

Instead of these:

const isNotAvailable = !page.get('_isAvailable');
if (isNotAvailable) continue;

const isNotAvailable = !page.get('_isAvailable');
if (isNotAvailable) continue;

Do this:

      const isNotShown = !page.get('_isAvailable') || page.get('_isHidden');
      if (isNotShown) continue;

That way, the next and prev buttons will not refer to _isHidden pages unless otherwise specified by _customRouteId and _isHidden will otherwise not change the behaviour of the buttons.

@swashbuck swashbuck self-assigned this Jun 21, 2024
github-actions bot pushed a commit that referenced this issue Jun 25, 2024
## [3.1.5](v3.1.4...v3.1.5) (2024-06-25)

### Fix

* Prevent _customRouteId from being ignored, allow hidden content objects (fixes #68 #69) ([7182f8f](7182f8f)), closes [#68](#68) [#69](#69)
Copy link

🎉 This issue has been resolved in version 3.1.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
2 participants