mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
22 lines
620 B
Swift
22 lines
620 B
Swift
import LayoutKit
|
|
|
|
final class FocusElementActionHandler {
|
|
func handle(_ action: DivActionFocusElement, context: DivActionHandlingContext) {
|
|
guard let elementId = action.resolveElementId(context.expressionResolver) else {
|
|
return
|
|
}
|
|
|
|
let cardId = context.cardId
|
|
if let previousCard = context.blockStateStorage.getFocusedElement()?.cardId,
|
|
previousCard != cardId {
|
|
context.updateCard(.state(previousCard))
|
|
}
|
|
|
|
context.blockStateStorage.setFocused(
|
|
isFocused: true,
|
|
element: IdAndCardId(id: elementId, cardId: cardId)
|
|
)
|
|
context.updateCard(.state(cardId))
|
|
}
|
|
}
|