Skip to content

Modal - onOpen or afterOpen hook? #101

Answered by rtivital
cstrat asked this question in Q&A
Discussion options

You must be logged in to vote

I've released 1.3.0-alpha-0 with new autofocus feature for use-focus-trap hook. Here is my findings and solution:

  • react does not add autofocus attribute to elements (we cannot target that with use-focus-trap)
  • to make api more simple I've added [data-focusable] selector handling to specify initial focus element
import React, { useState } from "react";
import { Button, Input, Tabs, Tab, Modal } from "@mantine/core";

export default function App() {
  const [isOpen, setOpen] = useState(false);

  return (
    <div>
      <Button onClick={() => setOpen(true)}>Open Modal</Button>
      <Modal opened={isOpen} onClose={() => setOpen(false)} hideCloseButton>
        <Tabs>
          <Tab label="…

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
4 replies
@rtivital
Comment options

@cstrat
Comment options

@rtivital
Comment options

@rtivital
Comment options

Comment options

You must be logged in to vote
7 replies
@rtivital
Comment options

@cstrat
Comment options

@cstrat
Comment options

@rtivital
Comment options

@cstrat
Comment options

Answer selected by cstrat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants