sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

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

Open jonathanhotono opened this issue 9 years ago • 16 comments

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,

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 avatar May 11 '17 20:05 StfBauer

@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.

jonathanhotono avatar May 24 '17 02:05 jonathanhotono

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?

matthong avatar Jun 01 '17 18:06 matthong

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.

jonathanhotono avatar Jun 05 '17 23:06 jonathanhotono

Seems that the issue happens in IE 11 and Chrome, but not in Firefox. Post a question to StackExchange: https://sharepoint.stackexchange.com/questions/218265/using-a-tag-in-spfx-web-part-causes-the-whole-page-re-rendered-in-modern-site

matthong avatar Jun 14 '17 22:06 matthong

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>'; }

matthong avatar Jun 22 '17 14:06 matthong

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

CANUSA avatar Jun 26 '17 14:06 CANUSA

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.

shaipetel avatar Jul 18 '17 17:07 shaipetel

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.

shaipetel avatar Jul 18 '17 18:07 shaipetel

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

manishgarg1 avatar Jul 18 '17 21:07 manishgarg1

That will be great! Thank you @manishgarg1.

matthong avatar Jul 18 '17 21:07 matthong

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

jonathanhotono avatar Sep 22 '17 02:09 jonathanhotono

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 29 '20 12:01 msft-github-bot