andykais / forager-web

0 stars 0 forks source link

focus system #3

Open andykais opened 3 years ago

andykais commented 3 years ago

focus is currently a ton of boolean flags all over the place. This is difficult because parent components sometimes need to trigger focus in child components, so we need several booleans for focus and focus_input, etc. Instead we should have a single focus enum which is shared between most components. E.g.

const focus: 'thumbnail-grid' | 'media_reference' | 'search'

we could get more fine-tuned w/ 'search:input' | 'search:suggestions' ...etc but that requires labeling reused components like search/tag.svelte.

Controlling focus from a parent component can be done by bind:this on child components and declaring functions as consts. We should be able to call them like search_el.focus() (which would call tag_search_el.focus())

andykais commented 3 years ago

[edit] we need a "focus stack" because if Im focused on the "Add New Tags" dialogue and I hit Escape, I need to know if I should return focus to the media_file or the thumbnail_grid