Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Dec 29, 2023
1 parent 8b33923 commit 556e29b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion components/lib/accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DomHandler, classNames, IconUtils, mergeProps, ObjectUtils, UniqueCompo
import { AccordionBase, AccordionTabBase } from './AccordionBase';
import { ChevronRightIcon } from '../icons/chevronright';
import { ChevronDownIcon } from '../icons/chevrondown';
import { PrimeReactContext, ariaLabel } from '../api/Api';
import { PrimeReactContext } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';

export const AccordionTab = () => {};
Expand Down Expand Up @@ -116,24 +116,28 @@ export const Accordion = React.forwardRef((inProps, ref) => {

const onTabArrowDownKey = (event) => {
const nextHeaderAction = findNextHeaderAction(event.target.parentElement.parentElement);

nextHeaderAction ? changeFocusedTab(nextHeaderAction) : onTabHomeKey(event);
event.preventDefault();
};

const onTabArrowUpKey = (event) => {
const prevHeaderAction = findPrevHeaderAction(event.target.parentElement.parentElement);

prevHeaderAction ? changeFocusedTab(prevHeaderAction) : onTabEndKey(event);
event.preventDefault();
};

const onTabHomeKey = (event) => {
const firstHeaderAction = findFirstHeaderAction();

changeFocusedTab(firstHeaderAction);
event.preventDefault();
};

const onTabEndKey = (event) => {
const lastHeaderAction = findLastHeaderAction();

changeFocusedTab(lastHeaderAction);
event.preventDefault();
};
Expand All @@ -146,12 +150,14 @@ export const Accordion = React.forwardRef((inProps, ref) => {
const findNextHeaderAction = (tabElement, selfCheck = false) => {
const nextTabElement = selfCheck ? tabElement : tabElement.nextElementSibling;
const headerElement = DomHandler.findSingle(nextTabElement, '[data-pc-section="header"]');

return headerElement ? (DomHandler.getAttribute(headerElement, 'data-p-disabled') ? findNextHeaderAction(headerElement.parentElement) : DomHandler.findSingle(headerElement, '[data-pc-section="headeraction"]')) : null;
};

const findPrevHeaderAction = (tabElement, selfCheck = false) => {
const prevTabElement = selfCheck ? tabElement : tabElement.previousElementSibling;
const headerElement = DomHandler.findSingle(prevTabElement, '[data-pc-section="header"]');

return headerElement ? (DomHandler.getAttribute(headerElement, 'data-p-disabled') ? findPrevHeaderAction(headerElement.parentElement) : DomHandler.findSingle(headerElement, '[data-pc-section="headeraction"]')) : null;
};

Expand Down
1 change: 0 additions & 1 deletion components/lib/scrollpanel/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export const ScrollPanel = React.forwardRef((inProps, ref) => {
};

const onKeyDown = (event) => {
console.log('hey?');
if (orientationState === 'vertical') {
switch (event.code) {
case 'ArrowDown': {
Expand Down
6 changes: 6 additions & 0 deletions components/lib/tabview/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,28 @@ export const TabView = React.forwardRef((inProps, ref) => {

const onTabArrowRightKey = (event) => {
const nextHeaderAction = findNextHeaderAction(event.target.parentElement);

nextHeaderAction ? changeFocusedTab(nextHeaderAction) : onTabHomeKey(event);
event.preventDefault();
};

const onTabArrowLeftKey = (event) => {
const prevHeaderAction = findPrevHeaderAction(event.target.parentElement);

prevHeaderAction ? changeFocusedTab(prevHeaderAction) : onTabEndKey(event);
event.preventDefault();
};

const onTabHomeKey = (event) => {
const firstHeaderAction = findFirstHeaderAction();

changeFocusedTab(firstHeaderAction);
event.preventDefault();
};

const onTabEndKey = (event) => {
const lastHeaderAction = findLastHeaderAction();

changeFocusedTab(lastHeaderAction);
event.preventDefault();
};
Expand All @@ -198,6 +202,7 @@ export const TabView = React.forwardRef((inProps, ref) => {

const findNextHeaderAction = (tabElement, selfCheck = false) => {
const headerElement = selfCheck ? tabElement : tabElement.nextElementSibling;

return headerElement
? DomHandler.getAttribute(headerElement, 'data-p-disabled') || DomHandler.getAttribute(headerElement, 'data-pc-section') === 'inkbar'
? findNextHeaderAction(headerElement)
Expand All @@ -207,6 +212,7 @@ export const TabView = React.forwardRef((inProps, ref) => {

const findPrevHeaderAction = (tabElement, selfCheck = false) => {
const headerElement = selfCheck ? tabElement : tabElement.previousElementSibling;

return headerElement
? DomHandler.getAttribute(headerElement, 'data-p-disabled') || DomHandler.getAttribute(headerElement, 'data-pc-section') === 'inkbar'
? findPrevHeaderAction(headerElement)
Expand Down

0 comments on commit 556e29b

Please sign in to comment.