sindresorhus / hide-files-on-github

Chrome extension - Hide nonessential files from the GitHub file browser
https://chrome.google.com/webstore/detail/hide-files-on-github/lpnakhpaodhdkleejaehlapdhbgjbddp
MIT License
320 stars 36 forks source link

Toggle Button does not recall application state after MutationObserver fires #21

Closed radiovisual closed 8 years ago

radiovisual commented 8 years ago

Every time the addToggleBtn() function is called, and the Toggle Button is not loaded (and it never is after the Mutation occurred, which is why it needs to be continuously added), this line of code is run:

const toggleBtn = createHtml('<a class="hide-files-btn btn btn-sm">Show dotfiles</a>');

Which indiscriminately sets the button.textContent to "Show dotfiles", ignoring the application state before the Mutation occurred.

I am happy to help with a PR if you agree this is a problem.

radiovisual commented 8 years ago

You can recreate this problem by loading any github page, clicking the Toggle Button to say "Hide dotfiles", then clicking any of the tabs at the top (e.g., "Issues", "Pull Requests", etc) and then clicking back to the "Code" tab, then you will notice that the dotfiles are still showing, but the button now says "Show dotfiles"

sindresorhus commented 8 years ago

Yeah, looks like a bug. A pull request would be much appreciated :)