Open t-hamano opened 9 months ago
P.S. We don't need to solve this problem all at once with one PR, but I think it would be better to remove contexts step by step using multiple PRs.
If some values it would be useful to share as context, one other option is to break the context into smaller contexts for specific use cases and consume them as close to where they are needed as possible. Or just put some of the values in context. Either way, avoiding having one huge context is a good plan.
The original main purpose of context is to resolve redundant props passing as mentioned in this document. However, the tree of font-library-related components is not that deep, and there are many contexts that are once used and are never used.
These contexts should be able to be removed entirely by passing props or using an ad-hoc approach.
Not using a provider makes it easier to completely separate the modal dialog and the typography panel and delegate control of opening and closing modal dialog to a data store, as attempted in #58350.
Eventually, it will be easier to trigger the Font Library modal dialog via the command palette, as suggested in #54880.
The only concern, as mentioned in this comment, is that the initial state of the Font Library modal dialog is also context-managed. To solve this, we will need to add an argument to
openModal
in theinterfaces
package that defines the initial state.