Code Monkey home page Code Monkey logo

Comments (8)

jonom avatar jonom commented on August 25, 2024

Hi @purplespider looks like #46 is related. I pushed up a fix a while ago (tweaked it this morning) that I think should help you - would you be able to try this branch and report back if it solves the problem for you?

from silverstripe-betternavigator.

purplespider avatar purplespider commented on August 25, 2024

Thanks, Jono. just tried the fix-46 branch, and while you no longer get a JS error in the console on User Form pages, Better Navigator still doesn't appear. Displays on other pages fine.

Tested on fresh Silverstripe 4.6.0 and latest UserForms 5.6.0.

from silverstripe-betternavigator.

jonom avatar jonom commented on August 25, 2024

Interesting. I don't use UserForms myself so I may not get a chance to debug this further for now, sorry. If you're able to look in to it more let me know what you find!

from silverstripe-betternavigator.

jonom avatar jonom commented on August 25, 2024

I went further down the rabbit hole this morning. Problem seems to be that the result of Controller::handleAction() can be all kinds of things, including a Controller (API says only DBHTMLText|HTTPResponse but not true). This is accounted for later in the pipeline - Controller::handleRequest() calls Controller::prepareResponse which is responsible for rendering Controllers and things out to HTML. I guess we could replicate that functionality within BetterNavigatorExtension but it feels like overkill and probably doubles render effort.

The API documentation is pretty far off here, like RequestHandler::handleAction() says they only thing it can return is a HTTPResponse, but that conflicts with reality and comments in the code.

I don't see an extension point we can use at an appropriate point in the response pipeline to solve this issue but maybe there's a middleware we can use to check for a HTML response really late in the pipeline? @unclecheese would really value your input here. (Side note: this is why I insisted on tagging a major release for that seemingly innocent change 😅)

@purplespider can you please try installing v4 instead of v5 and see if that fixes the problem for you. You'll need to put $BetterNavigator in your main page template but otherwise it's almost the same as v5.

from silverstripe-betternavigator.

jonom avatar jonom commented on August 25, 2024

@purplespider possibly just changing UserForms to render the result would fix the issue for you. Change this part to

return $this->render([
    'Content' => DBField::create_field('HTMLText', $this->Content),
    'Form' => $this->Form()
]);

I guess that would probably constitute a breaking change though 🤷

from silverstripe-betternavigator.

purplespider avatar purplespider commented on August 25, 2024

Thanks for looking into this further, Jono.

@purplespider can you please try installing v4 instead of v5 and see if that fixes the problem for you. You'll need to put $BetterNavigator in your main page template but otherwise it's almost the same as v5.

Yep, I can confirm that v4 works fine on UserForms pages.

@purplespider possibly just changing UserForms to render the result would fix the issue for you. Change this part to

return $this->render([
    'Content' => DBField::create_field('HTMLText', $this->Content),
    'Form' => $this->Form()
]);

I guess that would probably constitute a breaking change though 🤷

Yep, this makes v5 work!

from silverstripe-betternavigator.

jonom avatar jonom commented on August 25, 2024

I think the solution for this is going to be re-adding support for $BetterNavigator in templates, but making it optional, so sites that are affected by this issue (e.g. any using UserForms) have a way to fix it, but otherwise it's unnecessary.

In the afterCallActionHandler we can probably do a simple strpos test to see if the BetterNavigator HTML or script has already been added, and skip adding it again if so.

from silverstripe-betternavigator.

purplespider avatar purplespider commented on August 25, 2024

That sounds sensible to me, Jono! Thanks.

from silverstripe-betternavigator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.