Skip to content

Commit b813185

Browse files
authored
[EuiButton] Support focusable disabled behavior with hasAriaDisabled prop (#9201)
1 parent 3e6528a commit b813185

File tree

59 files changed

+2107
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2107
-109
lines changed
5.66 KB
Loading
3.37 KB
Loading
11.4 KB
Loading
6.51 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- Added beta prop `hasAriaDisabled` to all base button components: `EuiButton`, `EuiButtonEmpty`, `EuiButtonIcon`, `EuibuttonGroup`, `EuiFilterButton`
2+
- Added `euiDisabledSelector` variable that combines CSS selectors `:disabled` and `[aria-disabled="true"]`
3+
- Added custom test matchers that check for both `disabled` and `aria-disabled` attributes:
4+
- React testing Library: `.toBeEuiDisabled()`
5+
- Enzyme: `.toHaveEuiDisabledProp()`
6+
- Cypress: `should('be.euiDisabled)`
7+

packages/eui/cypress/support/component.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import './keyboard/repeatRealPress';
2323
import './copy/select_and_copy';
2424
import './setup/mount';
2525
import './setup/realMount';
26+
import './setup/matchers';
2627
import './css/cssVar';
2728
import './helpers/wait_for_position_to_settle';
2829

packages/eui/cypress/support/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,15 @@ declare global {
6969
*/
7070
waitForPositionToSettle(): Chainable<JQuery<HTMLElement>>;
7171
}
72+
interface Chainer<Subject> {
73+
(chainer: 'be.euiDisabled'): Chainable<Subject>;
74+
(chainer: 'be.euiEnabled'): Chainable<Subject>;
75+
}
76+
}
77+
namespace Chai {
78+
interface Assertion {
79+
euiDisabled: Assertion;
80+
euiEnabled: Assertion;
81+
}
7282
}
7383
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { setupEuiCypressMatchers } from '../../../src/test/cypress';
10+
11+
setupEuiCypressMatchers();

packages/eui/cypress/support/setup/realMount.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88

99
import React, { ReactNode } from 'react';
1010
import './mount';
11+
import { MountOptions } from './mount';
1112

12-
const realMountCommand = (children: ReactNode) => {
13+
const realMountCommand = (children: ReactNode, options: MountOptions = {}) => {
1314
cy.mount(
1415
<>
1516
<div
1617
data-test-subj="cypress-real-event-target"
1718
style={{ height: '1px', width: '1px' }}
1819
/>
1920
{children}
20-
</>
21+
</>,
22+
options
2123
).then(() => {
2224
cy.get('[data-test-subj="cypress-real-event-target"]').realClick({
2325
position: 'topLeft',

packages/eui/scripts/compile-eui.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ async function compileBundle() {
249249
'optimize/es/test',
250250
].map((dir) => path.join(packageRootDir, dir));
251251

252-
const testRtlDTSFiles = new glob.Glob('test/rtl/**/*.d.ts', {
252+
const testDirectories = ['rtl', 'enzyme'];
253+
const testDTSFiles = new glob.Glob('test/**/*.d.ts', {
253254
cwd: srcDir,
254255
realpath: true,
255256
});
@@ -278,12 +279,17 @@ async function compileBundle() {
278279
},
279280
});
280281

281-
await fs.mkdir(path.join(dir, 'rtl'), { recursive: true });
282+
for (const testDir of testDirectories) {
283+
await fs.mkdir(path.join(dir, testDir), { recursive: true });
284+
}
282285

283-
for await (const filePath of testRtlDTSFiles) {
286+
for await (const filePath of testDTSFiles) {
284287
const fullPath = path.join(srcDir, filePath);
285-
const baseName = path.basename(filePath);
286-
await fs.copyFile(fullPath, path.join(dir, 'rtl', baseName));
288+
289+
const relativePath = filePath.replace(/^test\//, '');
290+
const destPath = path.join(dir, relativePath);
291+
292+
await fs.copyFile(fullPath, destPath);
287293
}
288294
}
289295

0 commit comments

Comments
 (0)