Skip to content

Conversation

@KristjanESPERANTO
Copy link
Contributor

@KristjanESPERANTO KristjanESPERANTO commented Dec 7, 2025

The method now uses async/await instead of Promise chains (.then()), making the control flow more linear and easier to follow.

Additionally, the execution order was improved: the fullscreen transition now completes before updating map._isFullscreen and firing events. This ensures that event listeners always receive the correct, up-to-date state.

A nice side effect of this change is that the code in _toggleState now reads more intuitively:

this.link.title = isFullscreen ? titleCancel : title;

Previously, the logic was inverted because the state hadn't been updated yet when the event fired.

Summary of changes:

  • Refactor: Convert toggleFullScreen to async/await for better readability.
  • Refactor: Centralize element and mode detection to reduce code duplication.
  • Refactor: Simplify _handleFullscreenChange detection for external exits (ESC key).
  • Improve: Synchronize state updates with fullscreen transition completion.
  • Adjust: Update _toggleState logic to align with the new execution order.

Note on _handleFullscreenChange

The new execution order required adjusting this method: since map._exitFired is now set before exit() (not after), the condition needed to also check map._isFullscreen to correctly detect external exits (ESC key).


This is a polish PR - there are no functional changes, but the code should now be easier to understand and maintain.

Copy link
Owner

@brunob brunob left a comment

Choose a reason for hiding this comment

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

As usual, thx for the detailed PR :)

@KristjanESPERANTO
Copy link
Contributor Author

I hope it's not annoying that I'm creating so many PRs! But I think it's worth it.

@brunob
Copy link
Owner

brunob commented Dec 7, 2025

I certainly won't blame people that give of their free time and provide help and such relevant contributions ! You can't imagine how i'm happy to see collaboration emerge on this project :)

@brunob
Copy link
Owner

brunob commented Dec 8, 2025

Any thought @BePo65 ?

@KristjanESPERANTO KristjanESPERANTO force-pushed the refactor-toggle-fullscreen branch from 355a470 to 1f6dce3 Compare December 8, 2025 16:15
- Convert toggleFullScreen to async/await for better readability
- Wait for fullscreen transition before updating state and firing events
- Simplify logic by centralizing element and mode detection
- Simplify _handleFullscreenChange detection for external exits (ESC key)
- Update state before firing events for correct event handler behavior
@KristjanESPERANTO KristjanESPERANTO force-pushed the refactor-toggle-fullscreen branch from 1f6dce3 to 05d25dc Compare December 8, 2025 16:31
@brunob brunob merged commit 1ac5eb8 into brunob:master Dec 8, 2025
2 checks passed
@brunob
Copy link
Owner

brunob commented Dec 8, 2025

Thx again, if it's ok for you let's wait January to push a new release (?)

@KristjanESPERANTO
Copy link
Contributor Author

If it's okay, a last release for this year would be nice, as the type definitions would then be included 🙂

@BePo65
Copy link
Contributor

BePo65 commented Dec 9, 2025

Even for me all these changes look very good.

@brunob
Copy link
Owner

brunob commented Dec 9, 2025

If it's okay, a last release for this year would be nice, as the type definitions would then be included 🙂

I will be unavailable next two weeks, so that's why i prefer to release after this break in way to be present if anything is broken with latest changes (but i'm sure it will be ok :))

@KristjanESPERANTO
Copy link
Contributor Author

Makes sense, no problem. Have a nice time! 🙂

@mickaeltr
Copy link

Hello @KristjanESPERANTO,
I was having a look at this and since you gently added the Typescript definitions, I am thinking they should be updated accordingly (e.g. returning Promise<void> instead of void for function signatures that changed)
Thank you

@KristjanESPERANTO
Copy link
Contributor Author

@mickaeltr Thanks for the hint. I will have a look in the next days 🙂

@brunob
Copy link
Owner

brunob commented Jan 7, 2026

@KristjanESPERANTO should we release a new version now, or wait a bit until you have time to take care of @mickaeltr hints ? (no hurry)

@KristjanESPERANTO
Copy link
Contributor Author

KristjanESPERANTO commented Jan 7, 2026

Release would be good 👍 I handled his hints via the last PR (#245) in commit 4b83cb5 🙂

@brunob
Copy link
Owner

brunob commented Jan 8, 2026

Et voilà, version 5.2.0 is published :)

@KristjanESPERANTO
Copy link
Contributor Author

KristjanESPERANTO commented Jan 8, 2026

Nice! And I've created a PR to remove the types for leaflet.fullscreen from DefinitelyTyped: DefinitelyTyped/DefinitelyTyped#74316 🙂

Since the types are now here in the repo, they are superfluous there.

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.

4 participants