MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / MixedImperativeExample

Function MixedImperativeExample

src/test/tooltip-imperative.spec.js:181–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179
180 test('tooltip can be reopened imperatively when the same instance also has declarative anchor behavior', async () => {
181 const MixedImperativeExample = () => {
182 const tooltipRef = useRef(null)
183
184 return (
185 <>
186 <section id="section-anchor-select">
187 <p>
188 <button data-tooltip-id="anchor-select">Anchor select</button>
189 <button data-tooltip-id="anchor-select">Anchor select 2</button>
190 </p>
191 <Tooltip
192 ref={tooltipRef}
193 id="tooltip-content"
194 anchorSelect="section[id='section-anchor-select'] > p > button"
195 place="bottom"
196 openEvents={{ click: true }}
197 closeEvents={{ click: true }}
198 globalCloseEvents={{ clickOutsideAnchor: true }}
199 >
200 Tooltip content
201 </Tooltip>
202 </section>
203
204 <button
205 id="imperativeTooltipButton"
206 onClick={() => {
207 tooltipRef.current?.open({
208 anchorSelect: '#imperativeTooltipButton',
209 content: <div>Opened imperatively!</div>,
210 })
211 }}
212 >
213 imperative tooltip
214 </button>
215 </>
216 )
217 }
218
219 render(<MixedImperativeExample />)
220

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected