Commit Graph

43 Commits

Author SHA1 Message Date
Robin Malfait 93e8b8f4ba fix: outside click behaviour (#19)
* add failing tests to prove the outside-click issue

* fix outside click when we have multiple menu's

- We removed the `toggleMenu` since we only used it in a single spot,
  and had to do some side effect logic (focus & event.preventDefault).
  Wanted to make this consistent between React and Vue.
- If, in the "outside click" logic we detect that we clicked on the
  button, we also ignore it.
- If, we click on the button we will toggle the menu.

Fixes: #18
2020-09-28 15:52:00 +02:00
Robin Malfait e9fd05e06d ensure that anchor links are still clickable
This is an issue in the Vue version (it just works in the React version)
but I added tests for them anyway.

While this solution "works" I am not 100% happy with it. Let me explain
what's happening here and why I am not that happy about it:

- For starters, the Vue `nextTick` is apparently too fast. So what we do
  is when we get the pointer up event, we will close the menu and
  re-focus the button. We ran this code in a `nextTick` so that we can
  ensure that we close the menu *after* all the click events are
  finished. However because this is too fast, the menu is already closed
  and the anchor link is already unmounted and thus not clickable
  anymore. So instead we use a double requestAnimationFrame (to mimick a
  `nextFrame` as seen in the `disposables` from the React code). This
  works, but a bit messy, oh well.
- The next reason why I am not that happy is because I can't reproduce
  it in JSDOM (Jest tests). When you *click* a link in JSDOM it doesn't
  update the `window.location.hash` or `window.location.href`. To mimick
  that behaviour I put a `@click` event on the anchor to verify that we
  actually clicked it. However this already works, even before the
  "fix". So I left a TODO in there so that we can hopefully fix the
  test, so that we _can_ reproduce this behaviour.

Fixes: #14
2020-09-28 12:30:52 +02:00
Robin Malfait 93f315b066 add prepublishOnly hooks 2020-09-25 16:11:52 +02:00
Robin Malfait 3709ed5b77 only passthrough the aria-disabled prop when true
Drop the disabled prop itself because doesn't make much sense
2020-09-25 16:10:47 +02:00
Robin Malfait 2747745891 ensure that you can not click disabled items 2020-09-25 16:09:40 +02:00
Robin Malfait b229857b90 fix typo 2020-09-25 12:42:31 +02:00
Robin Malfait c5b83ec381 drop unneeded types in tsconfig.json 2020-09-25 12:41:57 +02:00
Robin Malfait 57caacdce8 add extra tests to verify that @click works on MenuItem as='button' 2020-09-25 12:40:56 +02:00
Juan Luis Rojas León 46a33b2fbd docs(React): jsx wrapped in enclosing tags (@headlessui-react/readme.md) (#10) 2020-09-25 10:54:16 +02:00
Utkarsh Kukreti 6d6be636d3 docs(React): fix "Transition" link href in @headlessui-react readme (#9) 2020-09-25 10:51:37 +02:00
Nathan Jaremko 20ddb3e639 docs(React): improve documentation for Menu transitions (#7)
* Improve documentation for Menu transitions

* Update README.md
2020-09-25 10:49:56 +02:00
Adam Wathan b051f13d80 docs: Add demo links 2020-09-24 13:41:16 -04:00
Robin Malfait 8add6f43f7 version 0.1.1 2020-09-24 12:56:25 +02:00
Robin Malfait 4a6048ef6c make examples between Vue and React consistent 2020-09-21 23:25:09 +02:00
Robin Malfait f7d26b55a1 use correct prettier settings 2020-09-21 16:34:53 +02:00
Robin Malfait 55c9adaa8a build code snippets for the Vue playground 2020-09-21 16:29:12 +02:00
Robin Malfait 1f29594414 add Menu examples in React 2020-09-21 12:50:44 +02:00
Robin Malfait 8cc424c820 use absolute path instead of relative 2020-09-21 12:50:44 +02:00
Robin Malfait f6883677f5 add Menu examples in Vue 2020-09-21 12:50:39 +02:00
Robin Malfait bd389b3b1e fix vercel build for the Vue playground 2020-09-20 21:46:06 +02:00
Robin Malfait d479be59dd configure vercel for routing 2020-09-20 21:29:56 +02:00
Robin Malfait 458466aa2a add playground:build script 2020-09-20 21:18:39 +02:00
Robin Malfait eed9f85b93 prerender 404 pages with a table of contents of all examples 2020-09-20 21:18:27 +02:00
Robin Malfait abc71184c8 cleanup scripts
use git command instead of some random realpath that is not installed everywhere
2020-09-20 20:47:39 +02:00
Robin Malfait 2ddb607f8c fix vite package alias 2020-09-20 20:47:00 +02:00
Robin Malfait eb441a13b0 generate all example paths at build time 2020-09-19 00:25:37 +02:00
Robin Malfait 110a01790b make the vue playground buildable for Vercel 2020-09-18 23:20:46 +02:00
Robin Malfait 62243344e3 bump dependencies 2020-09-18 17:20:45 +02:00
Robin Malfait b989ba4fdc Merge pull request #1 from tailwindlabs/document-react-components
docs: Document React Menu, tweak Transition and Vue docs to be consistent
2020-09-18 16:41:04 +02:00
Robin Malfait b7d53fdf3e add vue as a peer dependency 2020-09-18 14:32:39 +02:00
Robin Malfait 93508e97a3 remove test code, use mocks instead 2020-09-18 14:05:22 +02:00
Robin Malfait 273c0d9fda improve tsdx build 2020-09-17 23:25:16 +02:00
Robin Malfait 1b896b4992 add some dead code elimination markers 2020-09-17 23:24:40 +02:00
Robin Malfait 5f377b946e use headlessui identifier instead of tailwindui 2020-09-17 16:00:50 +02:00
Robin Malfait 59870594c1 inline defaultState
Otherwise we will be mutating the refs, and items from the first Menu on the page
2020-09-17 15:58:37 +02:00
Robin Malfait 6757fad6a4 use correct package reference 2020-09-17 11:01:51 +02:00
Robin Malfait 76c24680c5 make render logic consistent with the Vue implementation 2020-09-16 23:44:38 +02:00
Adam Wathan 4b0207ad71 docs: Document React Menu, tweak Transition and Vue docs to be consistent 2020-09-16 15:07:02 -04:00
Adam Wathan 7dcf6211f4 docs: Add 'Dropdown' alias next to Menu Button in TOC 2020-09-16 13:06:12 -04:00
Robin Malfait 8b546f054b setup @headlessui/react package 2020-09-16 18:20:49 +02:00
Robin Malfait f20b7f845b setup @headlessui/vue package 2020-09-16 18:19:54 +02:00
Robin Malfait 672afbe9f8 setup monorepo 2020-09-16 18:19:33 +02:00
Robin Malfait cf289e443a init project 2020-09-16 11:55:27 +02:00