Skip to content

Fix the info button bug#147

Merged
giswqs merged 5 commits intomainfrom
info
Nov 23, 2025
Merged

Fix the info button bug#147
giswqs merged 5 commits intomainfrom
info

Conversation

@giswqs
Copy link
Copy Markdown
Member

@giswqs giswqs commented Nov 23, 2025

Activate the button briefly then activate the info button.

Copilot AI review requested due to automatic review settings November 23, 2025 14:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an info button bug where the info button doesn't work on the first click. The fix implements a workaround that briefly activates and deactivates the remove button to initialize handlers when the info button is first activated.

Key Changes:

  • Added a workaround mechanism in JavaScript that programmatically clicks the remove button twice with a 50ms delay to initialize handlers
  • Modified the info mode disable logic to skip during the workaround execution
  • Changed the Python default value for show_info_box parameter from None to False

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
anymap/static/maplibre_widget.js Added _activatingWorkaround flag and workaround logic to initialize handlers by programmatically clicking the remove button; modified info mode disable check to skip during workaround
anymap/maplibre.py Changed show_info_box parameter default from None to False

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread anymap/static/maplibre_widget.js Outdated
Comment on lines +5702 to +5706
const geomanInstance = map.gm || el._geomanInstance;
const containerEl = geomanInstance?.control?.container;
if (containerEl) {
const buttons = Array.from(containerEl.querySelectorAll('.gm-control-button'));
const getButtonLabel = (b) => ((b.getAttribute('title') || b.getAttribute('aria-label') || (b.textContent ? b.textContent.trim() : '')).toLowerCase());
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getButtonLabel function is duplicated from lines 5686-5687 above. Consider extracting this into a shared function or constant defined once in the scope to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment thread anymap/static/maplibre_widget.js
Comment thread anymap/static/maplibre_widget.js
Comment thread anymap/maplibre.py Outdated
controls: Optional[Dict[str, Any]] = None,
collapsed: Optional[bool] = False,
show_info_box: Optional[bool] = None,
show_info_box: Optional[bool] = False,
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default value from None to False is a breaking change for existing users who rely on the previous default behavior. The docstring at line 2908-2910 states 'Defaults to None (no change in frontend default)' which is now inconsistent with the new default of False. Consider either reverting to None or updating the documentation to reflect the new default behavior.

Suggested change
show_info_box: Optional[bool] = False,
show_info_box: Optional[bool] = None,

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 23, 2025

@github-actions github-actions Bot temporarily deployed to pull request November 23, 2025 15:01 Inactive
giswqs and others added 3 commits November 23, 2025 10:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pull request November 23, 2025 15:12 Inactive
@giswqs giswqs merged commit 8f965ad into main Nov 23, 2025
8 checks passed
@giswqs giswqs deleted the info branch November 23, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants