Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle tab in autoselect #354

Merged
merged 2 commits into from
Oct 5, 2017
Merged

Conversation

tmepple
Copy link
Contributor

@tmepple tmepple commented Oct 5, 2017

Previously, pressing tab on an autocomplete field would move to the next tabbable element on the page but leave the dropdown open. This PR closes the dropdown while permitting native tab handling to move to the next element.

Additionally, if there is a hovered option it will select it (the same as pressing enter) and move to the next element. This provides for even faster data entry especially when used in conjunction with the keep-first option.

@jtommy
Copy link
Member

jtommy commented Oct 5, 2017

@tmepple It's good! Thanks!

@jtommy jtommy merged commit e9592ce into buefy:dev Oct 5, 2017
@tmepple
Copy link
Contributor Author

tmepple commented Oct 6, 2017

Thanks for the extremely fast review @jtommy!

@tmepple tmepple deleted the handle-tab-in-autoselect branch October 6, 2017 00:56
kikuomax added a commit to kikuomax/buefy that referenced this pull request Jan 8, 2025
* feat(lib): rewrite Taginput in TS

Rewrites `Taginput.vue` in TypeScript:
- Statically names imported Buefy components so that type checking
  works:
  - `[Autocomplete.name]: Autocomplete` → `BAutocomplete`
  - `[Tag.name]: Tag` → `BTag`
- Introduces pseudo type parameters `T` and `U`, which are `any`:
  - `T`: type of a tag
  - `U`: type of inputs given to `beforeAdding` and `createTag`, and the
    item type of `data` given to `b-autocomplete`. `addTag` accepts `U`
    but some code in `addTag` assumes the input is a string, so it won't
    work if it is strictly typed.

The following seemingly trivial changes might be breaking:
- Changes the type of `maxtags`: `[Number, String]` → `Number`. Because
  there is no reason to accept `String`. A breaking change anyway.
- Removes `rounded` prop because it is equivalent to the one defined in
  `FormElementMixin`. Should not be a breaking change.
- Removes the argument given to `focus` which is defined in
  `FormElementMixin`. Should not be a breaking change.
- `onTyping` adds a condition to tell `number` or `string` because
  `number` has no `trim`. Handlers of `typing` events can no longer
  assume the payloads are strings.

A remarkable breaking change:
- Removes `autocomplete` prop because it conflicts with the one defined
  in `FormElementMixin`; `Boolean` in the former and `String` in the
  latter. This discrepancy caused wierd type errors that seemingly
  unrelated props and methods became `never`.

  Unfortunately, the meanings of `autocomplete` are different between
  `Taginput` and `FormElementMixin`. I think we have two options:
  - Rename `autocomplete` of `Taginput`; it was `select-only` in the
    past
  - Remove `autocomplete` from `FormElementMixin`

  For now, `autocomplete` is removed from `Taginput` and inherited from
  `FormElementMixin`. Since `autocomplete` is supposed to be given
  without value, an empty string also turns on the autocomplete feature.

The following change is trivial but I want to mention the reason for it:
- Removes double asterisks from comments to prevent `api-extractor` from
  picking them up for document generation

* test(lib): rewrite spec for Taginput in TS

- Rewrites `components/taginput/Taginput.spec.js` in TypeScript:
    - Replaces the extension: `.js` → `.ts`
    - Imports necessary methods from `vitest`
    - Appends `.vue` extensions to import paths of Buefy components

  Replaces `autocomplete`: `true` → an empty string (`''`). Because the
  type of `autocomplete` prop was changed: `boolean` → `string`. An
  empty string represents an attribute given without value, which is
  the most likely use case of `autocomplete`.

- Replaces `Taginput.spec.js.snap` with `Taginput.spec.ts.snap`.

* chore(lib): bundle Taginput as TS

`rollup.config.mjs` removes `taginput` from `JS_COMPONENTS`.

* feat(docs): rewrite Taginput examples in TS

Rewrites the examples of `Taginput` in `pages/components/taginput` in
TypeScript.

Adds missing types. The following changes might not be trivial:
- `getFilteredTags` method in examples `ExAutocomplete`, `ExSelected`,
  and `ExTemplatedAutocomplete` deals with the situation where the input
  is `number` or `undefined`

Corrects type errors.
- `maxtags` prop no longer accepts `string`
- `autocomplete` prop is not `boolean` but `string`. Explicitly binds
  `"on"` to it

Here is a TypeScript migration tip:
- Explicitly import and register components so that they are type
  checked. No type-checking is performed for globally registered
  components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants