Skip to content

Commit 3a698b0

Browse files
authored
Merge pull request #1595 from dxc-technology/gomezivann-fix-focuslock
Fix Focus Lock issue
2 parents f3ddde5 + 649e734 commit 3a698b0

File tree

6 files changed

+29
-35
lines changed

6 files changed

+29
-35
lines changed

lib/src/button/Button.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const DxcButton = ({
4242
type={type}
4343
mode={mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode}
4444
disabled={disabled}
45-
aria-disabled={disabled}
4645
tabIndex={disabled ? -1 : tabIndex}
4746
backgroundType={backgroundType}
4847
size={size}

lib/src/tabs/Tab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const Tab = forwardRef(
1818
type="button"
1919
tabIndex={tabIndex}
2020
disabled={tab.isDisabled}
21-
aria-disabled={tab.isDisabled}
2221
aria-selected={active}
2322
hasLabelAndIcon={hasLabelAndIcon}
2423
iconPosition={iconPosition}
@@ -124,15 +123,16 @@ const TabContainer = styled.button<{
124123
opacity: 1;
125124
}
126125
127-
&[aria-disabled="true"] {
126+
&:disabled {
128127
background-color: ${(props) => props.theme.unselectedBackgroundColor} !important;
129128
cursor: not-allowed !important;
130129
pointer-events: all;
131130
font-style: ${(props) => props.theme.disabledFontStyle};
131+
outline: none !important;
132+
132133
svg {
133134
color: ${(props) => props.theme.disabledIconColor};
134135
}
135-
outline: none !important;
136136
> div {
137137
opacity: 0.5;
138138
}

lib/src/tabs/Tabs.tsx

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const DxcTabs = ({
102102

103103
const scrollLeft = () => {
104104
const scrollWidth = refTabList?.current?.offsetWidth * 0.75;
105-
let moveX;
105+
let moveX = 0;
106106
if (countClick <= scrollWidth) {
107107
moveX = 0;
108108
setScrollLeftEnabled(false);
@@ -118,7 +118,7 @@ const DxcTabs = ({
118118

119119
const scrollRight = () => {
120120
const scrollWidth = refTabList?.current?.offsetWidth * 0.75;
121-
let moveX;
121+
let moveX = 0;
122122
if (countClick + scrollWidth + refTabList?.current?.offsetWidth >= totalTabsWidth) {
123123
moveX = totalTabsWidth - refTabList?.current?.offsetWidth;
124124
setScrollRightEnabled(false);
@@ -221,7 +221,7 @@ const DxcTabs = ({
221221
<ScrollIndicator
222222
onClick={scrollLeft}
223223
enabled={enabledIndicator}
224-
aria-disabled={!scrollLeftEnabled}
224+
disabled={!scrollLeftEnabled}
225225
aria-label={translatedLabels.tabs.scrollLeft}
226226
tabIndex={scrollLeftEnabled ? tabIndex : -1}
227227
minHeightTabs={minHeightTabs}
@@ -251,20 +251,20 @@ const DxcTabs = ({
251251
onMouseLeave={() => {
252252
onTabHover?.(null);
253253
}}
254-
></Tab>
254+
/>
255255
))}
256256
</TabList>
257257
<ActiveIndicator
258258
tabWidth={activeIndicatorWidth}
259259
tabLeft={activeIndicatorLeft}
260260
aria-disabled={isActiveIndicatorDisabled}
261-
></ActiveIndicator>
261+
/>
262262
</TabsContentScroll>
263263
</TabsContent>
264264
<ScrollIndicator
265265
onClick={scrollRight}
266266
enabled={enabledIndicator}
267-
aria-disabled={!scrollRightEnabled}
267+
disabled={!scrollRightEnabled}
268268
aria-label={translatedLabels.tabs.scrollRight}
269269
tabIndex={scrollRightEnabled ? tabIndex : -1}
270270
minHeightTabs={minHeightTabs}
@@ -278,10 +278,10 @@ const DxcTabs = ({
278278
};
279279

280280
const Underline = styled.div`
281+
position: absolute;
281282
left: 0;
282283
bottom: 0;
283284
width: 100%;
284-
position: absolute;
285285
height: ${(props) => props.theme.dividerThickness};
286286
background-color: ${(props) => props.theme.dividerColor};
287287
`;
@@ -313,17 +313,17 @@ const ScrollIndicator = styled.button<{
313313
enabled: boolean;
314314
minHeightTabs: number;
315315
}>`
316+
box-sizing: border-box;
316317
display: ${(props) => (props.enabled ? "flex" : "none")};
317-
background-color: #ffffff;
318-
font-size: 1.25rem;
318+
justify-content: center;
319319
min-width: ${(props) => props.theme.scrollButtonsWidth};
320320
height: ${(props) => props.minHeightTabs - 1}px;
321321
padding: 0;
322-
justify-content: center;
323-
cursor: pointer;
324-
border-bottom: solid ${(props) => props.theme.dividerThickness} ${(props) => props.theme.dividerColor};
325-
box-sizing: border-box;
326322
border: none;
323+
background-color: #ffffff;
324+
font-size: 1.25rem;
325+
cursor: pointer;
326+
327327
&:hover {
328328
background-color: ${(props) => `${props.theme.hoverBackgroundColor} !important`};
329329
}
@@ -334,15 +334,7 @@ const ScrollIndicator = styled.button<{
334334
&:active {
335335
background-color: ${(props) => `${props.theme.pressedBackgroundColor} !important`};
336336
}
337-
svg {
338-
height: 20px;
339-
width: 20px;
340-
align-self: center;
341-
fill: ${(props) => props.theme.unselectedFontColor};
342-
visibility: visible;
343-
}
344-
&[aria-disabled="true"] {
345-
pointer-events: none;
337+
&:disabled {
346338
cursor: default;
347339
svg {
348340
visibility: hidden;
@@ -355,23 +347,29 @@ const ScrollIndicator = styled.button<{
355347
background-color: transparent !important;
356348
}
357349
}
350+
351+
svg {
352+
align-self: center;
353+
height: 20px;
354+
width: 20px;
355+
fill: ${(props) => props.theme.unselectedFontColor};
356+
}
358357
`;
359358

360359
const ActiveIndicator = styled.span<{ tabLeft: number; tabWidth: number }>`
360+
position: absolute;
361+
bottom: 0;
361362
left: ${(props) => `${props.tabLeft}px`};
362363
width: ${(props) => `${props.tabWidth}px`};
363-
background-color: ${(props) => props.theme.selectedUnderlineColor};
364-
bottom: 0;
365364
height: ${(props) => props.theme.selectedUnderlineThickness};
366-
position: absolute;
365+
background-color: ${(props) => props.theme.selectedUnderlineColor};
367366
&[aria-disabled="true"] {
368367
background-color: ${(props) => props.theme.disabledFontColor};
369368
display: none;
370369
}
371370
`;
372371

373372
const TabsContent = styled.div`
374-
display: flex;
375373
flex: 1 1 auto;
376374
display: inline-block;
377375
position: relative;

lib/src/textarea/Textarea.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ describe("Textarea component tests", () => {
5151
test("Renders with correct accesibility attributes", () => {
5252
const { getByLabelText } = render(<DxcTextarea label="Example label" />);
5353
const textarea = getByLabelText("Example label");
54-
expect(textarea.getAttribute("aria-disabled")).toBe("false");
5554
expect(textarea.getAttribute("aria-invalid")).toBe("false");
5655
expect(textarea.getAttribute("aria-describedBy")).toBeNull();
5756
expect(textarea.getAttribute("aria-required")).toBe("true");
@@ -65,11 +64,10 @@ describe("Textarea component tests", () => {
6564
expect(textarea.value).toBe("Example text");
6665
});
6766

68-
test("Disabled textarea renders with correct aria and can not be modified", () => {
67+
test("Disabled textarea can not be modified", () => {
6968
const onChange = jest.fn();
7069
const { getByLabelText } = render(<DxcTextarea label="Example label" onChange={onChange} disabled />);
7170
const textarea = getByLabelText("Example label");
72-
expect(textarea.getAttribute("aria-disabled")).toBe("true");
7371
userEvent.type(textarea, "Test");
7472
expect(onChange).not.toHaveBeenCalled();
7573
});

lib/src/textarea/Textarea.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ const DxcTextarea = React.forwardRef<RefType, TextareaPropsType>(
121121
backgroundType={backgroundType}
122122
ref={textareaRef}
123123
tabIndex={tabIndex}
124-
aria-disabled={disabled}
125124
aria-invalid={error ? "true" : "false"}
126125
aria-errormessage={error ? errorId : undefined}
127126
aria-required={optional ? "false" : "true"}

lib/src/utils/FocusLock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
33
const not = {
44
inert: ":not([inert]):not([inert] *)",
55
negTabIndex: ':not([tabindex^="-"])',
6-
disabled: ":not(:disabled):not([aria-disabled='true'])",
6+
disabled: ":not(:disabled)",
77
};
88
const focusableQuery = [
99
`a[href]${not.inert}${not.negTabIndex}`,

0 commit comments

Comments
 (0)