Sp-dev-docs: BUG: Using <a /> tag causing whole webpart to be re-rendered in modern site page

Created on 11 May 2017  路  16Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

I'm using normal <a role="button" /> tag with onClick events to interact with the UI, this works fine in both Classic pages and /_layouts/workbench.aspx page, however when I deploy this to modern page I noticed that each time I clicked on the tag it always re-render the whole webpart again.

This issue also occurs on normal <a href="#" ></a> tag without any onClick event,

Most helpful comment

Hi @shaipetel, @matthong

thanx for reporting the issue and apologies for a delayed response. We have identified a potential issue in our code and will try to provide a fix soon. Once that fix ships, most likely this issue should go away.

regards

All 16 comments

Have you tried to override the onClick event, because even when you don't have an onClick handler attached the browser by default hast on.

Haven't tried it myself but looks a bit strange.

@StfBauer Sorry for the delay, yes I did tried to to override using event.preventDefault()and event.stopPropagation(). It still re-render the whole webpart.

I have noticed the same behavior. This is particularly an issue when using third party components that render tags which you have no control over.

We are facing the same problem when using a 3rd party library which uses " href='#' " for dropdown menus. Any idea when the bug can be fixed?
Is there a workaround for this issue?

Fyi @iclanton @VesaJuvonen .
This probably isn't an issue with spfx and probably with the o365 modern page bug. Not sure where else to report this bug.

In my case, it is all about the number sign "#". If I remove the "#" from 'href="#"', then everything works, the re-rendering doesn't happen.

The issue can be reproduced with the following code in a Hello World Web Part

public render(): void {
alert('render() called by clicking the A tag');
this.domElement.innerHTML = '<a href="#" onclick="return false;">Click me</a>';
}

@patmill @VesaJuvonen Any chance we could get this triaged? Seems to be a pretty easy to repro, common problem.

I noticed the same issue, I had to modify an external library I was using to stop rendering a tags with href='#', I replaced it with href='javascript:' and it seemed to work.
Give it a try, although regardless this needs to be fixed.

I noticed it on classic web part pages, not only on modern so it is probably not the modern page that is causing this. Other non-SPFx web parts did not have this issue on the same page.

My web part was using knockout framework.

well then, good luck. I reported this several months ago and got no feedback so I couldn't wait on our release to production date, I had to create a copy of that library and changed it to work.

Hopefully this will get fixed this time around, seems to be getting more attention this time. It is a very big issue IMHO. I'll keep following this thread.

Hi @shaipetel, @matthong

thanx for reporting the issue and apologies for a delayed response. We have identified a potential issue in our code and will try to provide a fix soon. Once that fix ships, most likely this issue should go away.

regards

That will be great! Thank you @manishgarg1.

I can confirm this issue is now fixed. Closing the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karishmaTCS picture karishmaTCS  路  3Comments

mikeparkie picture mikeparkie  路  3Comments

qrown picture qrown  路  3Comments

jonthenerd picture jonthenerd  路  3Comments

christianbueschi picture christianbueschi  路  3Comments