microsoft / tabster

Web Application Keyboard Navigation Tools
https://tabster.io
MIT License
116 stars 34 forks source link

feat(mover): make isDefault always win against other props #353

Open smhigley opened 6 months ago

smhigley commented 6 months ago

Chatted with @ling1726 about this some time ago, this PR updates Mover to have isDefault always "win" when determining which element to focus when tabbing into a group.

This is related to work on Copilot messages (https://github.com/microsoft/tabster/issues/348), where we want memorizeCurrent, but sometimes need to override it, e.g. when a new message comes in.

micahgodbolt commented 6 months ago

if a user has 'isDefault' set, what is the best approach for actually using memorizeCurrent? Do you have to wait for focus, and then remove the 'isDefault' prop from the item? Do we need some callback to make sure we remove isDefault after focus has successfully been moved to the item?

smhigley commented 6 months ago

@micahgodbolt yeah, I think the approach from the copilot side of things would be to set isDefault when a new message comes in, and remove it once the element gets focus

mshoho commented 5 months ago

This unconditionally alters the existing behaviour and might break some existing expectations. This behaviour either needs additional prop (like priority for memorizeCurrent) or the goal should be achieved differently (we were discussing custom DOM event like tabster:mover:memorized that you can dispatch to make Mover forget or alter memorized element (passing the desired action in the event details). @micahgodbolt what would be more convenient for your scenario? I think custom event would work better. I can do the adjustment today, this waits for my reaction for too long already.

smhigley commented 5 months ago

@mshoho the event approach sounds good to me, that sounds like it’ll address our use case.

If you let me know when the change is available, I’ll try it out in Fluent AI 👍