-
-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix attibution controll #668
Conversation
Bundle size report: Size Change: +12 B
ℹ️ View Details
|
I tested ( bd1ee4b ) and still no luck with that version. However, comparing the html I find if I change
to
it seems to work as expected. This change is based on comparing the old html to the new html you can see all the classes are there, it just wasn't displaying anything as a details/summary instead of div/button. |
I am currently comparing the Attribution Control in the current developer version with version 1.15.2. |
@acalcutt Thank you very much for your support. You are right. I made the changes ( But you are also right. Of course, it has to work error-free. It now works for me with the changes in this PR with your example. I added the unminified JavaScript file (Attribution control is on line 36794) to a fork of your stackblitz here: https://stackblitz.com/edit/web-platform-jrpt1q?file=maplibre-gl.js Is this working for you or am I missing something? |
Still not working. What this version does is slightly different. When it starts small on stackblitz, the button works as expected. If i then expand the window the button goes away and the attribution text shows (still good). However when I shrink the window again, the button comes back with a blank attribution
The thing you missed is attribution shows by default unless you add "attributionControl: false," to the map options. So you are seeing the default one, plus the one you added. I only know this because I just moved my attribution to a different position, and when you do that you have to do the same thing or you get a double attribution button ( https://maplibre.org/maplibre-gl-js-docs/example/attribution-position/ )
|
I looked over the code more and don't really see a reason details/summary works differently than the divs, but it does. Do you at least see what I mean in the video above when you try that with your example ( https://stackblitz.com/edit/web-platform-jrpt1q?file=maplibre-gl.js ) This is the same example with just details/summary put back to divs, which works fine for me The logic for showing/hiding the button looks right to me...and the same code works with the divs so it is strange |
The HTML elements
Yes, thank you for the explanation. Now I have seen it. I think it's fixed with the last commit, but I want to check tomorrow. |
I have tested again and in my case |
I haven't tested the latest version, but here's what I see when I look at the code: |
I tested 92e230e and I though you had it fixed. In chrome it works as expected. But I was trying it in firefox and noticed one other strange issue that didn't happen in the old version In firefox, when the window was small enough to show the button I clicked to expand it. I then resized the window just a little (not enough to show the full attribution as text, but a little bigger). When I did that the attribution text disappeared and I was back to that blank attribution button. if i toggled it, it stayed blank. It started working again if I made the window big enough to show text and then made it small again. |
…mode, if it changed from big to small size
If I see this correctly, there are 3 possible states (not two: compact and not compact): Only for compact = undefined is the The HTML elements Our variant for I hope I have explained this in an understandable way. If my current version is still incorrect, I would restore the original code (with div and button). @acalcutt |
I tested the latest version and it now works as I would expect. Thanks for taking the time to fix it and making it more compliant. |
This reverts commit 0b81a41.
@acalcutt Thank you for testing. |
I got rid of the "compact" variable all together. It calls _updateCompact() when OnAdd is run, and also sets it to run _updateCompact() on a map resize event. _updateCompact() already sets the classes and the open attribute the way it seems to need. This is a clean compare of the changes I made, mixed with astridx's other fixes ( https://github.com/maplibre/maplibre-gl-js/compare/main...acalcutt:fix_attributes?expand=1 ) |
Here is a working example for testing https://stackblitz.com/edit/web-platform-wgdui8?file=maplibre-gl.js |
Comparing the code it seems that the following scenario will yield different results: |
Well you did make me realize I was ignoring the compact option completely, so I also just added this change to UpdateCompact() to fix that (basically adding a check for the compact option, or a size <640).
But to me that seems like it would affect compact = true not false. Reading the documentation, if compact = false suppsed to expand the button when below 640?
|
I think I've fixed the issue with compact = false below 640. I made this update to _updateCompact() (https://github.com/maplibre/maplibre-gl-js/compare/main...acalcutt:fix_attributes?expand=1)
I've updated the example here ( https://stackblitz.com/edit/web-platform-mw4nqr?file=index.html ) so the compact option can be set. It seems to work as I would expect with compact = true, compact = false, or compact not defined now |
it was giving me a headache
This looks good. We need to make sure we have the following tests to basically test all these scenarios right?
|
Please see #713 (comment) |
I think the changes in the tests that are in this file should be changed to be order agnostic. Other than that, I think this PR is ready to be merged. |
@HarelM That is now so, or am I missing something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I read the changes incorrectly. Good job!!
* main: (98 commits) [Jest] Migrate `geojson_worker_source.test.js` (maplibre#731) Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (maplibre#726) (maplibre#727) Define return type of getSource as possibly undefined (maplibre#724) Fix attibution controll (maplibre#668) Fix start-debug to watch ts files (maplibre#704) [Jest] Migrate `touch_zoom_rotate.test.js` (maplibre#721) [Jest] Migrate `requestRenderFrame.test.js` (maplibre#722) [Jest] Migrate `scroll_zoom.test.js` (maplibre#712) [Jest] Migrate `marker.test.js` (maplibre#696) [Jest] Migrate `mouse_rotate.test.js` (maplibre#711) [Jest] Migrate `keyboard.test.js` (maplibre#707) [Jest] Migrate `map_event.test.js` (maplibre#710) [Jest] Migrate `drag_rotate.test.js` (maplibre#709) Handle spies and call counts (maplibre#708) [Jest] Migrate `drag_pan.test.js` (maplibre#702) Add type for styleimagemissing event (maplibre#703) Fix MapDataEvent#isSourceLoaded being true in GeoJSONSource "dataloading" event handlers (maplibre#694) (maplibre#695) [Jest] Migrate `dblclick_zoom.test.js` (maplibre#697) [Jest] Migrate `popup.test.js` (maplibre#687) Fixed typo (maplibre#698) ...
* pluggable-render: (102 commits) WIP - pluggable render update Removed a badly typed variable [Jest] Migrate `geojson_worker_source.test.js` (maplibre#731) Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (maplibre#726) (maplibre#727) Define return type of getSource as possibly undefined (maplibre#724) Fix attibution controll (maplibre#668) Fix start-debug to watch ts files (maplibre#704) Filter out hillshade layers Filter out hillshade styles [Jest] Migrate `touch_zoom_rotate.test.js` (maplibre#721) [Jest] Migrate `requestRenderFrame.test.js` (maplibre#722) [Jest] Migrate `scroll_zoom.test.js` (maplibre#712) [Jest] Migrate `marker.test.js` (maplibre#696) [Jest] Migrate `mouse_rotate.test.js` (maplibre#711) [Jest] Migrate `keyboard.test.js` (maplibre#707) [Jest] Migrate `map_event.test.js` (maplibre#710) [Jest] Migrate `drag_rotate.test.js` (maplibre#709) Handle spies and call counts (maplibre#708) [Jest] Migrate `drag_pan.test.js` (maplibre#702) Add type for styleimagemissing event (maplibre#703) ...
Fix for #640 (comment)
The attribute
open
should only added to thedefault
view if the size is less than 640 pixel. Because only then the toggle works correct, because less than 640 the attribution control is forced to becompact
(line 73).