MCPcopy Index your code
hub / github.com/reactstrap/reactstrap / handleDocumentClick

Method handleDocumentClick

src/Dropdown.js:91–128  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

89 }
90
91 handleDocumentClick(e) {
92 if (
93 e &&
94 (e.which === 3 || (e.type === 'keyup' && e.which !== keyCodes.tab))
95 )
96 return;
97 const container = this.getContainer();
98 const menu = this.getMenu();
99 const toggle = this.getToggle();
100
101 // Add a conditional check to avoid using toggle
102 // if there is no toggle component in the dropdown
103 if (!toggle) {
104 return;
105 }
106
107 const targetIsToggle = toggle.contains(e.target);
108
109 const clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
110
111 let clickIsInInput = false;
112 if (container) {
113 // This is only for InputGroup with type dropdown
114 clickIsInInput =
115 container.classList.contains('input-group') &&
116 container.classList.contains('dropdown') &&
117 e.target.tagName === 'INPUT';
118 }
119
120 if (
121 ((targetIsToggle && !clickIsInInput) || clickIsInMenu) &&
122 (e.type !== 'keyup' || e.which === keyCodes.tab)
123 ) {
124 return;
125 }
126
127 this.toggle(e);
128 }
129
130 handleKeyDown(e) {
131 const isTargetMenuItem =

Callers

nothing calls this directly

Calls 4

getContainerMethod · 0.95
getMenuMethod · 0.95
getToggleMethod · 0.95
toggleMethod · 0.95

Tested by

no test coverage detected