Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.36k stars 76 forks source link

ScopedServices.HandlesBack doesn't match if the key is `ScopeKey.Child`, but not `ScopeKey`, and the explicit parent scope is defined by a previous key as well #210

Closed Zhuinden closed 4 years ago

Zhuinden commented 4 years ago

Currently found this bug, which is disconcerting.

Apparently despite the tests for findScopeForKey(key, ScopeLookupMode.EXPLICIT), this can somehow still fail to return the explicit scope registrations for that key, if the key has no scope registration on itself, but the previous key has also registered an explicit parent scope by the same name.

Which means that dispatchBack() doesn't find the explicit parent if the scope name is registered by the previous scope, if the scope is only ScopeKey.Child, but not ScopeKey.

Having a scope registration with ScopeKey solves this, as from the "node-wise" scope, a registration is found, and its explicit parent is evaluated based on its associated parent scopes.

Will fix ASAP, which is probably tomorrow.

Zhuinden commented 4 years ago

Fixed in https://github.com/Zhuinden/simple-stack/commit/781525c0d95d49ad0c13d286ca9c2ddb4f91125b

This was an artifact of being an incomplete solution in https://github.com/Zhuinden/simple-stack/issues/201 which is unfortunate.

Zhuinden commented 4 years ago

@matejdro I encountered this while tinkering with HandlesBack + the explicit parent scoping mechanics you've outlined, so you might be affected by this.

I've released the fix in 2.2.1.

matejdro commented 4 years ago

Thanks. I did not use HandlesBack, so this did not affect me.