Skip to content

Commit

Permalink
fix(docs,core,platform): various fixes from deffect hunt (#10168)
Browse files Browse the repository at this point in the history
* fix(platform): fixed platform form generator skeleton paddings

* feat(core): added missing list item byline property

* fix(platform): fixed HTML structure of the message view error

* chore(docs,core,platform): replaced deprecated selector usages

* fix(cdk,docs): fixed incorrect deprecation. input was effectively removed without replacement

* chore(core): removed unnecessary comments

* fix(docs): fixed incorrect paths to the modules

* fix(docs): added missing sub package

* chore: fixed e2e test
  • Loading branch information
g-cheishvili authored Jul 13, 2023
1 parent 0acc46c commit 00b858b
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ import { TabbableElementService } from '../../services/tabbable-element.service'
}
]
})
export class DeprecatedInitialFocusDirective extends DeprecatedSelector {}
export class DeprecatedInitialFocusDirective extends DeprecatedSelector {
/** @hidden */
private _initialFocusDirective = inject(InitialFocusDirective, { host: true });

/**
* CSS selector of an element that should be focused.
*/
@Input('fd-initial-focus')
set initialFocusTarget(value: string) {
this._initialFocusDirective.fdkInitialFocus = value;
}
}

@Directive({
selector: '[fdkInitialFocus], [fdInitialFocus], [fd-initial-focus]',
Expand All @@ -38,8 +49,8 @@ export class InitialFocusDirective implements AfterViewInit {
/**
* CSS selector of an element that should be focused.
*/
@Input('fd-initial-focus')
focusableItem = '.fd-initial-focus-item';
@Input()
fdkInitialFocus = '.fd-initial-focus-item';

/**
* Whether initial focus enabled for a current element.
Expand Down Expand Up @@ -105,13 +116,14 @@ export class InitialFocusDirective implements AfterViewInit {
* Searches for an appropriate focusable element
*/
private _getFocusableElement(): HTMLElement | null {
if (!this.focusableItem) {
if (!this.fdkInitialFocus) {
return this._tabbableService.getTabbableElement(this._elmRef.nativeElement, this.focusLastElement);
}

const autoFocusableItems = this._elmRef.nativeElement.querySelectorAll(
this.focusableItem
this.fdkInitialFocus
) as NodeListOf<HTMLElement>;
console.log(autoFocusableItems);

if (autoFocusableItems.length > 0) {
return !this.focusLastElement ? autoFocusableItems[0] : autoFocusableItems[autoFocusableItems.length - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1 fd-title *ngIf="mobileConfig?.title">{{ mobileConfig.title }}</h1>
</fd-button-bar>
<fd-button-bar
*ngIf="mobileConfig?.cancelButtonText"
fd-initial-focus
fdkInitialFocus
[label]="mobileConfig.cancelButtonText!"
(click)="handleDismiss()"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 fd-title [id]="_defaultDialogContent?.titleId">{{ _defaultDialogContent?.tit
<fd-button-bar
*ngIf="_defaultDialogContent?.approveButton"
fdType="emphasized"
fd-initial-focus
fdkInitialFocus
[label]="_defaultDialogContent?.approveButton || ''"
[fdCozy]="_defaultDialogConfiguration.mobile"
(click)="_approveButtonClicked()"
Expand Down
7 changes: 7 additions & 0 deletions libs/core/src/lib/list/list-item/list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ export class ListItemComponent extends ListFocusItem implements AfterContentInit
@HostBinding('class.fd-list__item--unread')
unread = false;

/**
* Whether the list item is byline
*/
@Input()
@HostBinding('class.fd-list__item--byline')
byline = false;

/** @deprecated Text to be read by screen reader for selected list item */
@Input()
selectedListItemScreenReaderText: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1 fd-title>{{ title }}</h1>
</fd-button-bar>
<fd-button-bar
*ngIf="mobileConfig.cancelButtonText"
fd-initial-focus
fdkInitialFocus
[label]="mobileConfig.cancelButtonText"
(click)="close()"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 fd-title>{{ _messageBoxContent.title }}</h1>
<fd-message-box-footer *ngIf="_footerVisible">
<fd-button-bar
*ngIf="_messageBoxContent.approveButton"
fd-initial-focus
fdkInitialFocus
fdType="emphasized"
[label]="_messageBoxContent.approveButton"
[ariaLabel]="_messageBoxContent.approveButtonAriaLabel"
Expand Down
9 changes: 0 additions & 9 deletions libs/core/src/lib/select/select.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@
>
<fd-icon [glyph]="glyph"></fd-icon>
</span>
<!-- <button-->
<!-- fd-button-->
<!-- tabindex="-1"-->
<!-- class="fd-button&#45;&#45;transparent fd-select__button {{ selectDropdownButtonClass }}"-->
<!-- (click)="_buttonClick()"-->
<!-- *ngIf="!readonly"-->
<!-- [disabled]="disabled"-->
<!-- [glyph]="glyph"-->
<!-- ></button>-->
</div>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
have access to the event handler.
</p>
</description>
<import module="ClickedBehaviorModule" subPackage="cdk"></import>
<import module="ClickedBehaviorModule" subPackage="utils"></import>

<fd-header-tabs></fd-header-tabs>
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
to your component.
</p>
</description>
<import module="DisabledBehaviorModule" subPackage="cdk"></import>
<import module="DisabledBehaviorModule" subPackage="utils"></import>

<fd-header-tabs></fd-header-tabs>
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
It also respects <code>[fdkDisabled]</code> directive, so that those elements will be excluded from the selection
sequence.
</description>
<import module="FocusableGridModule" subPackage="cdk"></import>
<import module="FocusableGridModule" subPackage="utils"></import>

<fd-header-tabs></fd-header-tabs>
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
directions, and it also respects <code>[fdkDisabled]</code> directive, so that those elements will be excluded from
the selection sequence.
</description>
<import module="FocusableListModule" subPackage="cdk"></import>
<import module="FocusableListModule" subPackage="utils"></import>

<fd-header-tabs></fd-header-tabs>
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

<div class="fdk-initial-focus-examples">
<div *ngIf="currentExample === 'link'">
<a fd-initial-focus [routerLink]="['./']" fd-link aria-label="Standard">Link with autofocus</a>
<a fdkInitialFocus [routerLink]="['./']" fd-link aria-label="Standard">Link with autofocus</a>
</div>
<div *ngIf="currentExample === 'button'">
<button fd-initial-focus fd-button>Button with autofocus</button>
<button fdkInitialFocus fd-button>Button with autofocus</button>
</div>
<div *ngIf="currentExample === 'input'">
<div fd-form-item>
<label fd-form-label for="input-1">Default Input</label>
<input fd-initial-focus fd-form-control type="text" id="input-1" placeholder="Input with autofocus" />
<input fdkInitialFocus fd-form-control type="text" id="input-1" placeholder="Input with autofocus" />
</div>
</div>
<div *ngIf="currentExample === 'textarea'">
<div fd-form-item>
<label fd-form-label for="input-1">Default Textarea</label>
<textarea
fd-initial-focus
fdkInitialFocus
fd-form-control
type="text"
id="textarea-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<div class="fdk-initial-focus-examples">
<div *ngIf="currentExample === 'select'">
<fd-select fd-initial-focus=".fd-select__button" placeholder="Autofocusable select">
<fd-select fdkInitialFocus=".fd-select__control" placeholder="Autofocusable select">
<li fd-option *ngFor="let option of options" [value]="option">{{ option }}</li>
</fd-select>
</div>
<div *ngIf="currentExample === 'combobox'">
<fd-combobox
fd-initial-focus
fdkInitialFocus
inputId="comboboxID1"
ariaLabel="Standard"
maxHeight="250px"
Expand All @@ -24,7 +24,7 @@
</div>
<div *ngIf="currentExample === 'datepicker'">
<fd-date-picker
fd-initial-focus=".fd-input-group__button"
fdkInitialFocus=".fd-input-group__button"
type="single"
inputId="datePicker"
[(ngModel)]="date"
Expand All @@ -33,7 +33,7 @@
<div *ngIf="currentExample === 'textarea'">
<div fd-form-item>
<fd-slider
fd-initial-focus
fdkInitialFocus
[focusLastElement]="true"
mode="range"
tooltipMode="editable"
Expand Down
6 changes: 3 additions & 3 deletions libs/docs/cdk/initial-focus/initial-focus-docs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</component-example>
<code-example [exampleFiles]="initialFocusDefaultExample"></code-example>
<separator></separator>
<fd-docs-section-title id="nested" componentName="InitialFocus"
>Initial focus with nested elements</fd-docs-section-title
>
<fd-docs-section-title id="nested" componentName="InitialFocus">
Initial focus with nested elements
</fd-docs-section-title>
<description>
<p>By default, initial focus directive will try to focus element to which this directive is applied.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can quickly build out selectable list collection for your components. For that you will need to use combination
of <code>[fdkSelectableList]</code> and <code>[fdkSelectableItem]</code>
</description>
<import module="SelectableListModule" subPackage="cdk"></import>
<import module="SelectableListModule" subPackage="utils"></import>

<fd-header-tabs></fd-header-tabs>
<router-outlet></router-outlet>
2 changes: 1 addition & 1 deletion libs/docs/core/dialog/dialog-docs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</li>
<li>
By default after opening the Dialog first focusable element will be focused. To focus specific element after
opening the Dialog, use <code>fd-initial-focus</code> directive.
opening the Dialog, use <code>fdkInitialFocus</code> directive.
</li>
</ul>
</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3 fd-illustrated-message-title>Unable to load data</h3>
</fd-dialog-body>

<fd-dialog-footer>
<fd-button-bar fd-initial-focus fdType="emphasized" label="Reload"></fd-button-bar>
<fd-button-bar fdkInitialFocus fdType="emphasized" label="Reload"></fd-button-bar>
<fd-button-bar label="Close" (click)="dialog.dismiss('Close button')"></fd-button-bar>
</fd-dialog-footer>
</fd-dialog>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1 id="fd-message-box-template-base-header" fd-title>Fruit facts</h1>
</fd-message-box-body>
<fd-message-box-footer>
<fd-button-bar
fd-initial-focus
fdkInitialFocus
label="Ok"
fdType="emphasized"
(click)="messageBox.close('Ok')"
Expand Down
2 changes: 1 addition & 1 deletion libs/docs/core/message-box/message-box-docs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</li>
<li>
By default after opening the message box first focusable element will be focused. To focus specific element
after opening the message box, use <code>fd-initial-focus</code> directive.
after opening the message box, use <code>fdkInitialFocus</code> directive.
</li>
</ul>
</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1 id="fd-dialog-popover-1" fd-title>Popover Example</h1>
<fd-dialog-body>
<fd-popover [noArrow]="false">
<fd-popover-control>
<button fdInitialFocus fd-button label="Click me!" aria-describedby="fd-dialog-button-1"></button>
<button fdkInitialFocus fd-button label="Click me!" aria-describedby="fd-dialog-button-1"></button>
</fd-popover-control>
<fd-popover-body>
<div id="fd-dialog-button-1" style="padding: 12px">This is the button's popover!</div>
Expand Down
2 changes: 1 addition & 1 deletion libs/docs/core/tabs/e2e/tabs.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TabsPo extends CoreBaseComponentPo {
titleField = '#playgroundtitle';
counterField = '#playgroundcounter';
iconSelect = '#playgroundicon ';
acceleratedIcon = this.iconSelect + 'option:nth-child(2)';
acceleratedIcon = this.iconSelect + 'option[value="accelerated"]';
fdIcon = this.playGroundExample + 'fd-icon';

async open(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<fd-dialog-footer>
<fd-button-bar fdType="emphasized" label="Continue" type="submit" (click)="dialog.close('Continue')">
</fd-button-bar>
<fd-button-bar fd-initial-focus label="Cancel" (click)="dialog.dismiss()"> </fd-button-bar>
<fd-button-bar fdkInitialFocus label="Cancel" (click)="dialog.dismiss()"> </fd-button-bar>
</fd-dialog-footer>
</fd-dialog>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
the user switches between tab pages by clicking the respective tab.
</p>
</description>
<import module="PlatformIconTabBarModule"></import>
<import module="PlatformIconTabBarModule" subPackage="icon-tab-bar"></import>

<fd-header-tabs></fd-header-tabs>
</fd-doc-page>
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h4 fd-title [headerSize]="6">{{ group.title }} form</h4>

<fd-dialog-footer>
<fd-button-bar fdType="emphasized" label="Yes" type="submit" (click)="dialog.close(true)"> </fd-button-bar>
<fd-button-bar fd-initial-focus label="No" (click)="dialog.dismiss()"> </fd-button-bar>
<fd-button-bar fdkInitialFocus label="No" (click)="dialog.dismiss()"> </fd-button-bar>
</fd-dialog-footer>
</fd-dialog>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fd-dialog-decisive-button
fdType="transparent"
[label]="'platformApprovalFlow.addNodeCancelActionBtnLabel' | fdTranslate"
Expand All @@ -189,7 +189,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fdType="transparent"
[label]="'platformApprovalFlow.addNodeCancelApproverSelectionActionBtnLabel' | fdTranslate"
(click)="_exitSelectMode()"
Expand All @@ -211,7 +211,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fdType="transparent"
[label]="'platformApprovalFlow.addNodeCancelApproverSelectionActionBtnLabel' | fdTranslate"
(click)="_exitSelectMode()"
Expand All @@ -223,7 +223,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fdType="transparent"
[label]="'platformApprovalFlow.addNodeApproverOrTeamDetailsCloseActionBtnLabel' | fdTranslate"
(click)="_exitTeamMembersMode()"
Expand All @@ -235,7 +235,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fdType="transparent"
[label]="'platformApprovalFlow.addNodeApproverOrTeamDetailsCloseActionBtnLabel' | fdTranslate"
(click)="_exitUserDetailsMode()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fd-dialog-decisive-button
fdType="transparent"
[label]="'platformApprovalFlow.userDetailsCancelBtnLabel' | fdTranslate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<fd-dialog-footer-button>
<button
fd-button
fd-initial-focus
fdkInitialFocus
fd-dialog-decisive-button
fdType="transparent"
[label]="'platformApprovalFlow.selectTypeDialogCancelButton' | fdTranslate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</fd-busy-indicator>

<ng-template #loadingTemplate>
<fd-skeleton width="100%" height="100px">
<fd-skeleton width="100%" height="100px" style="padding: 1rem">
<svg:rect x="0" y="0" rx="4" width="15%" height="8" />
<svg:rect x="0" y="20" rx="4" width="25%" height="16" />

Expand Down
Loading

0 comments on commit 00b858b

Please sign in to comment.