Skip to content

Commit 8cd6937

Browse files
authored
feat: Add data-focused attribute to manage focus state (#160)
* feat: Add data-focused attribute to manage focus state * feat: optional chainin added
1 parent e6ac578 commit 8cd6937

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [2.2.3]
8+
## Fixed
9+
- Enhanced native DOM focus behavior by adding and removing the data-focused attribute during focus transitions.
10+
711
# [2.2.2]
812
## Added
913
- New export for `SpatialNavigation` core service with types

src/SpatialNavigation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,8 @@ class SpatialNavigationService {
14511451
focusDetails
14521452
);
14531453

1454+
oldComponent.node?.removeAttribute?.('data-focused');
1455+
14541456
this.log('setCurrentFocusedKey', 'onBlur', oldComponent);
14551457
}
14561458

@@ -1463,6 +1465,8 @@ class SpatialNavigationService {
14631465
newComponent.node.focus(this.domNodeFocusOptions);
14641466
}
14651467

1468+
newComponent.node?.setAttribute?.('data-focused', 'true');
1469+
14661470
newComponent.onUpdateFocus(true);
14671471
newComponent.onFocus(
14681472
this.getNodeLayoutByFocusKey(this.focusKey),

0 commit comments

Comments
 (0)