MithrilJS / mithril.js

A JavaScript Framework for Building Brilliant Applications
https://mithril.js.org
MIT License
13.98k stars 925 forks source link

Update component when clicking anchor #2555

Open yueduz opened 4 years ago

yueduz commented 4 years ago

mithril@2.0.4

Chromium and Linux

mithril updated the component when I clicked on the anchor. I think doing nothing but scrolling the page is the correct behavior.

I have done the following settings

m.route.prefix = ""
pygy commented 4 years ago

IIRC I already shared your assessment around the v1.0 release, but Leo disagreed and he was still running the show.

We can probably revisit this.

ChrisGitIt commented 4 years ago

Hi everybody, isn't this a case for "ev.preventDefault()" or m.redraw = false?

@yueduz: What exactly are you doing? What is "the anchor"? You mean a named anchor?

osban commented 4 years ago

Yeah, onclick: e => e.redraw = false would work.

dead-claudia commented 4 years ago

@pygy Could you link to that discussion?

yueduz commented 4 years ago

大家好,“ ev.preventDefault()”或m.redraw = false是否不是这种情况?

@yueduz:您到底在做什么?什么是“锚”?你是说一个命名的锚?

Is a link containing a "#": https://blog.juying.co/content/Linux%E4%B8%8B%E4%BD%BF%E7%94%A8Mac%E9%94%AE%E7%BB%91%E5%AE%9A%E9%A3%8E%E6%A0%BC#%E5%BA%9F%E8%AF%9D%E8%AF%B4%E5%AE%8C%E4%BA%86%EF%BC%8C%E6%88%91%E4%BB%AC%E5%BC%80%E5%A7%8B

pygy commented 4 years ago

@isiahmeadows See #1270 (and also #1088 for a counter-argument)

StephanHoyer commented 2 years ago

won't fix for me

StephanHoyer commented 2 years ago

From the admin-channel by @dead-claudia

@StephanHoyer MithrilJS/mithril.js#2555 is probably worth fixing IMHO - I still stand with my comment in MithrilJS/mithril.js#1088. In general, we should only redraw on changes to the parts of the route that impact routing. Pathname: path + query Query: query only Hash: hash only I wouldn't count it as a release blocker, though, especially considering it's potentially breaking and best held for v3.

I'm ok with that