Conversation
There was a problem hiding this comment.
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_boxparameter fromNonetoFalse
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.
| 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()); |
There was a problem hiding this comment.
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.
| controls: Optional[Dict[str, Any]] = None, | ||
| collapsed: Optional[bool] = False, | ||
| show_info_box: Optional[bool] = None, | ||
| show_info_box: Optional[bool] = False, |
There was a problem hiding this comment.
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.
| show_info_box: Optional[bool] = False, | |
| show_info_box: Optional[bool] = None, |
|
🚀 Deployed on https://6923245502ee42dab1546cd1--opengeos.netlify.app |
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>
Activate the button briefly then activate the info button.