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

LPS-117287 Multiple clicks on links mess up SPA navigation #233

Closed
wants to merge 1 commit into from

Conversation

markocikos
Copy link
Collaborator

This is a bugfix, see description and discussion in https://issues.liferay.com/browse/LPS-117287. This ticket exposes several unrelated bugs, one of which we previously fixed in #171.

To reproduce, double(+)click on an edit link in journal. I added few console logs for gifs, as it is not clear when I click.

Before:
before

After:
after

Notes:

  • This issue is not only in Journal, it is all over the place. It is most noticeable when opening pages with editors, such as journal or blogs, but weird things can happen on any page. For example, management toolbar may render below page content. I was not brave enough to make the change on all links on the portal, or on all <aui:a> links. What would be the ideal scope for this kind of change?
  • Alternative to prevention is to handle the breakage on opening. I tried this, or example detecting if the editor already exist before creating it and destroying it, but nothing worked on a satisfactory level.

@liferay-continuous-integration
Copy link
Collaborator

To conserve resources, the PR Tester does not automatically run for every pull.

If your code changes were already tested in another pull, reference that pull in this pull so the test results can be analyzed.

If your pull was never tested, comment "ci:test" to run the PR Tester for this pull.

@brunobasto
Copy link

hey @markocikos is that only a problem for Journal or could this be happening with other links too? I remember that Senna is supposed to gracefully deal with multiple clicks and cancel the pending navigation and start a new one. If that's affecting other places we might need to fix that in Senna itself.

@markocikos
Copy link
Collaborator Author

markocikos commented Aug 11, 2020

@brunobasto It is happening with many other links. Senna sound like the right place for the change, I can give it a shot. Is this the correct repo to look in? I never worked on it, so I might need some pointers with integration, PRs, publishing etc.

@wincent
Copy link

wincent commented Aug 11, 2020

Is this the correct repo to look in?

That's the one.

@wincent
Copy link

wincent commented Aug 11, 2020

One thought before diving too heavily into Senna... (and perhaps a silly question) can we repro this behavior with SPA turned off?

@georgel-pop-lr
Copy link

One thought before diving too heavily into Senna... (and perhaps a silly question) can we repro this behavior with SPA turned off?

I heavily looked into this, and I was unable to reproduce it with senna off, for the moment this is the workaround we offer to our clients who had this issues and all confirm this issues stopped once SPA was disabled.

@markocikos
Copy link
Collaborator Author

@brunobasto @wincent Well, I force-pushed a solution. My confidence is very low that it's the best one 😄

Looking at Senna, I found that, indeed, there is a mechanism that prevents multiple clicks breakage, with pending navigation check. It is a part of app.navigate. The problem becomes, why isn't this triggered correctly in portal?

This solution is a bit nuclear, we are forcing navigate on every link. Let me paste it full here:

delegate(document, 'click', 'a', (event) => {
	const url = event.delegateTarget.href;

	if (app.canNavigate(url)) {
		app.navigate(url);
	}
});

This fixes the double-click bug portal-wide, but is also quite likely to break something. I'll run tests, am curious to see.

I would expect that enforcement like this exists somewhere, or we have some alternative mechanism that achieves auto-navigation. I couldn't find it, but intend to dig more. If you know it, please point me to it.

@markocikos
Copy link
Collaborator Author

ci:test:relevant

@brunobasto
Copy link

brunobasto commented Aug 12, 2020

@brunobasto @wincent Well, I force-pushed a solution. My confidence is very low that it's the best one 😄

Looking at Senna, I found that, indeed, there is a mechanism that prevents multiple clicks breakage, with pending navigation check. It is a part of app.navigate. The problem becomes, why isn't this triggered correctly in portal?

This solution is a bit nuclear, we are forcing navigate on every link. Let me paste it full here:

delegate(document, 'click', 'a', (event) => {
	const url = event.delegateTarget.href;

	if (app.canNavigate(url)) {
		app.navigate(url);
	}
});

This fixes the double-click bug portal-wide, but is also quite likely to break something. I'll run tests, am curious to see.

I would expect that enforcement like this exists somewhere, or we have some alternative mechanism that achieves auto-navigation. I couldn't find it, but intend to dig more. If you know it, please point me to it.

Hey Marko, I think this can introduce some regressions. Senna has its way of not targeting certain links (or even form submissions) when they have a data attribute data-senna-off. With this solution, it seems we are going to bypass that mechanism and that will likely introduce regressions.

I think we might need to dig a little deeper on this one. Looking at git history for both senna and frontend-js-web it seems they haven't had significant changes in a long time. I wonder if this broke recently or if it's just this bug is been there silent for a long time..

@brunobasto
Copy link

This might have something to do with it: https://github.com/liferay/senna.js/blob/master/src/app/App.js#L434

Maybe @diegonvs can share some insight (if he remembers this). The issue that introduced this cancellation policy was liferay/senna.js#262

@wincent
Copy link

wincent commented Aug 12, 2020

if he remembers this

Screenshot 2020-08-12 -192927-jch3MMp6@2x

i-remember-that

I have trouble remembering what I did yesterday... 👴

@brunobasto
Copy link

if he remembers this

Screenshot 2020-08-12 -192927-jch3MMp6@2x

i-remember-that

I have trouble remembering what I did yesterday... 👴

tenor-95542175

@diegonvs
Copy link

I don't remember easily which things were needed to change for having the pendingNavigations things working 😭 .

The problem becomes, why isn't this triggered correctly in portal?

It needs to be investigated deeply ;/

@diegonvs
Copy link

Watching Liferay.SPA.app.isNavigationPending on the console I notice the error:

VM4459 ckeditor.js:350 Uncaught TypeError: Cannot read property 'unselectable' of null
    at f (VM3121 ckeditor.js:350)
    at c.<anonymous> (VM3121 ckeditor.js:346)
    at c.d (VM3121 ckeditor.js:10)
    at c.<anonymous> (VM3121 ckeditor.js:12)
    at c.CKEDITOR.editor.CKEDITOR.editor.fire (VM3121 ckeditor.js:13)
    at c.fireOnce (VM3121 ckeditor.js:12)
    at c.CKEDITOR.editor.CKEDITOR.editor.fireOnce (VM3121 ckeditor.js:13)
    at Object.<anonymous> (VM3121 ckeditor.js:273)
    at e (VM3121 ckeditor.js:253)
    at Object.load (VM3121 ckeditor.js:253)

is being thrown before the isNavigationPending flag is settled to false.

@liferay-continuous-integration
Copy link
Collaborator

✔️ ci:test:stable - 21 out of 21 jobs passed

❌ ci:test:relevant - 51 out of 54 jobs passed in 1 hour 58 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 38b09127ba6c6277c9377c1d0bb78fbc07c90ae7

Copied in Private Modules Branch:

Branch Name: master-private
Branch GIT ID: a4eb9471e502819c1cfc9d16ef0eea0078d40a10

ci:test:stable - 21 out of 21 jobs PASSED
21 Successful Jobs:
ci:test:relevant - 51 out of 54 jobs PASSED
51 Successful Jobs:
For more details click here.

Failures unique to this pull:

For upstream results, click here.

@liferay-continuous-integration
Copy link
Collaborator

@markocikos
Copy link
Collaborator Author

Followup in liferay/senna.js#337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants