Skip to content

Commit 7eaf897

Browse files
committed
refactor(aria/toolbar): Add accessors for pattern properties
1 parent 73d37a3 commit 7eaf897

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/aria/toolbar/toolbar.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class Toolbar<V> {
169169
exportAs: 'ngToolbarWidget',
170170
host: {
171171
'class': 'ng-toolbar-widget',
172-
'[attr.data-active]': '_pattern.active()',
172+
'[attr.data-active]': 'active()',
173173
'[attr.tabindex]': '_pattern.tabindex()',
174174
'[attr.inert]': 'hardDisabled() ? true : null',
175175
'[attr.disabled]': 'hardDisabled() ? true : null',
@@ -202,6 +202,12 @@ export class ToolbarWidget<V> implements OnInit, OnDestroy {
202202
/** Whether the widget is 'hard' disabled, which is different from `aria-disabled`. A hard disabled widget cannot receive focus. */
203203
readonly hardDisabled = computed(() => this._pattern.disabled() && !this._toolbar.softDisabled());
204204

205+
/** Whether the widget is currently the active one (focused). */
206+
readonly active = computed(() => this._pattern.active);
207+
208+
/** The position of the widget within the toolbar. */
209+
readonly index = computed(() => this._pattern.index);
210+
205211
/** The ToolbarWidget UIPattern. */
206212
readonly _pattern = new ToolbarWidgetPattern<V>({
207213
...this,
@@ -253,6 +259,9 @@ export class ToolbarWidgetGroup<V> implements OnInit, OnDestroy {
253259
/** The controls that can be performed on the widget group. */
254260
readonly controls = signal<ToolbarWidgetGroupControls | undefined>(undefined);
255261

262+
/** The position of the widget within the toolbar. */
263+
readonly index = computed(() => this._pattern.index);
264+
256265
/** The ToolbarWidgetGroup UIPattern. */
257266
readonly _pattern = new ToolbarWidgetGroupPattern<V>({
258267
...this,

0 commit comments

Comments
 (0)