diff --git a/package.json b/package.json index 55587b4e382..d3b9445ff4a 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "remark-emoji": "^2.1.0", "remark-parse-no-trim": "^8.0.4", "remark-rehype": "^8.0.0", - "tabbable": "^5.2.1", + "tabbable": "^5.3.3", "text-diff": "^1.0.1", "unified": "^9.2.0", "unist-util-visit": "^2.0.3", @@ -155,7 +155,6 @@ "@types/react-dom": "^18.2.6", "@types/react-is": "^17.0.3", "@types/react-router-dom": "^5.3.3", - "@types/tabbable": "^3.1.2", "@types/testing-library__jest-dom": "^5.14.3", "@types/url-parse": "^1.4.8", "@types/uuid": "^8.3.0", diff --git a/scripts/jest/setup/mocks.js b/scripts/jest/setup/mocks.js index a98e1d98eee..d83925fd818 100644 --- a/scripts/jest/setup/mocks.js +++ b/scripts/jest/setup/mocks.js @@ -30,3 +30,18 @@ jest.mock('./../../../src/services/breakpoint/current_breakpoint_hook', () => { } = require('./../../../src/services/breakpoint/current_breakpoint_hook.testenv'); return { useCurrentEuiBreakpoint }; }); + +// @see https://github.com/focus-trap/tabbable#testing-in-jsdom +const mockTabbable = jest.requireActual('tabbable'); + +jest.mock('tabbable', () => ({ + ...mockTabbable, + tabbable: (node, options) => + mockTabbable.tabbable(node, { ...options, displayCheck: 'none' }), + focusable: (node, options) => + mockTabbable.focusable(node, { ...options, displayCheck: 'none' }), + isFocusable: (node, options) => + mockTabbable.isFocusable(node, { ...options, displayCheck: 'none' }), + isTabbable: (node, options) => + mockTabbable.isTabbable(node, { ...options, displayCheck: 'none' }), +})); diff --git a/yarn.lock b/yarn.lock index eb07241b749..915b90e97f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5019,11 +5019,6 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== -"@types/tabbable@^3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@types/tabbable/-/tabbable-3.1.2.tgz#5046f043fef50961d7727920b0076b37737e31ad" - integrity sha512-Yp+M5IjNZxYjsflBbSalyjUAIqiJyEISg++gLAstGrZlp9lzVi5KAsZvJqThT2qeoqGYnFqdZXorPEYtaVBAkg== - "@types/testing-library__jest-dom@^5.14.3", "@types/testing-library__jest-dom@^5.9.1": version "5.14.5" resolved "https://registry.yarnpkg.com/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.5.tgz#d113709c90b3c75fdb127ec338dad7d5f86c974f" @@ -20330,10 +20325,10 @@ synchronous-promise@^2.0.15: resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.17.tgz#38901319632f946c982152586f2caf8ddc25c032" integrity sha512-AsS729u2RHUfEra9xJrE39peJcc2stq2+poBXX8bcM08Y6g9j/i/PUzwNQqkaJde7Ntg1TO7bSREbR5sdosQ+g== -tabbable@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-5.2.1.tgz#e3fda7367ddbb172dcda9f871c0fdb36d1c4cd9c" - integrity sha512-40pEZ2mhjaZzK0BnI+QGNjJO8UYx9pP5v7BGe17SORTO0OEuuaAwQTkAp8whcZvqon44wKFOikD+Al11K3JICQ== +tabbable@^5.3.3: + version "5.3.3" + resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-5.3.3.tgz#aac0ff88c73b22d6c3c5a50b1586310006b47fbf" + integrity sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA== table@^6.8.1: version "6.8.1"