Refactor to consolidate focus state changes.