didierfred / SimpleModifyHeaders

Extension for firefox and chrome to modify headers
164 stars 30 forks source link

Prevent UI buttons from scrolling the user to the top #20

Closed Stopa closed 4 years ago

Stopa commented 4 years ago

Hello! Thank you for creating this extension, I use it very heavily at work every day.

I noticed a small but very annoying quirk: since all UI buttons were made as <a href="#"> and default event wasn't being prevented, every time you'd click on any of them, viewport would be scrolled to the top.

This PR addresses this concern: I simply rewrote the buttons to <button type="button">.

I thought I'd write the row html building as a template literal, making it a bit easier to scan and read.

Since bootstrap css is used, visually everything should remain exactly the same.

Also updated some code to make unit tests work - childNodes also includes text nodes (which there were many due to how the html is constructed now), whereas children gives only "actual" children.

I realise that this project is probably considered more or less feature-complete and not in very active development due to the simplicity of the extension, but reading the code was somewhat annoying because there's no consistent style in tabbing, bracket position etc. Would you be open to using, for example, ESLint or Prettier for code style rules? I didn't do it as part of this PR as it would affect almost the entire codebase.

didierfred commented 4 years ago

Hello,

Thanks for your modification , it works well .

Yes , no problem if you want to make consistent style , you can make another PR for that