kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 193 forks source link

allow to disable automatic link detection #705

Open macrozone opened 7 years ago

macrozone commented 7 years ago

flow router does interfer with every link on the page by attaching a listener to the document.

In react-apps there is no way to disable or hook into a link-click (by specifying a onClick on the link) with FlowRouter because of this. (onClick is never called).

The only way i found is to disable this global on click handler. There is an option for this in page.js, but its not accessible through FlowRouter, so i monkey-patched it:

FlowRouter._askedToWait = true;
Meteor.startup(function () {
  const oldPage = FlowRouter._page;
  FlowRouter._page = function (...args) {
    if (_.isObject(args[0])) {
      args[0].click = false;
    }
    return oldPage.call(this, ...args);
  };
  _.assign(FlowRouter._page, oldPage); // copy properties

  FlowRouter.initialize();
});

It would be easier to just be able to pass this option.