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

Focus newly added link variant option #1511

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"resolutions": {
"connected-next-router/react-redux": "8.0.7",
"react-beautiful-dnd/react-redux": "8.0.7",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"express": "4.20.0"
},
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
"dependencies": {
"@prismicio/simulator": "^0.1.4",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/plugin-kit": "workspace:*",
"common-tags": "^1.8.2",
"fp-ts": "^2.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"dependencies": {
"@prismicio/simulator": "^0.1.4",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/plugin-kit": "workspace:*",
"common-tags": "^1.8.2",
"fp-ts": "^2.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"dependencies": {
"@prismicio/simulator": "^0.1.4",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/plugin-kit": "workspace:*",
"common-tags": "^1.8.2",
"fp-ts": "^2.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"@prismicio/simulator": "^0.1.4",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/plugin-kit": "workspace:*",
"common-tags": "^1.8.2",
"fp-ts": "^2.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@prismicio/client": "^7.11.0",
"@prismicio/custom-types-client": "2.1.0",
"@prismicio/mocks": "2.5.0",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@segment/analytics-node": "^2.1.2",
"@slicemachine/plugin-kit": "workspace:*",
"cookie": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"devDependencies": {
"@prismicio/mock": "0.3.7",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
"@types/fs-extra": "11.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@prismicio/mock": "0.3.3",
"@prismicio/mocks": "2.5.0",
"@prismicio/simulator": "0.1.4",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@radix-ui/react-hover-card": "1.0.6",
"@radix-ui/react-tabs": "1.0.4",
"@reach/menu-button": "0.18.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TextInput,
Tooltip,
} from "@prismicio/editor-ui";
import { useRef } from "react";
import { Checkbox, Flex, Label } from "theme-ui";

import { Col } from "@/legacy/components/Flex";
Expand Down Expand Up @@ -122,6 +123,8 @@ export function Variants({

const deleteButtonShown = (variants?.length ?? 0) > 2;

const focusableInputIndex = useRef<number>();

return (
<Box overflow="hidden" flexDirection="column" border borderRadius={6}>
<Box
Expand Down Expand Up @@ -166,6 +169,11 @@ export function Variants({
borderRadius={4}
>
<TextInput
ref={(ref) => {
if (focusableInputIndex.current !== position) return;
focusableInputIndex.current = undefined;
ref?.focus();
}}
placeholder="Variant option (e.g. Primary)"
value={variant}
onValueChange={(newVariant) =>
Expand Down Expand Up @@ -194,7 +202,10 @@ export function Variants({
<Button
invisible
startIcon="add"
onClick={() => onVariantsChange([...(variants ?? []), ""])}
onClick={() => {
focusableInputIndex.current = variants?.length;
onVariantsChange([...(variants ?? []), ""]);
}}
>
Add option
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const linkConfigSchema = yup
allowText: yup.boolean().strict().optional(),
repeat: yup.boolean().strict().optional(),
variants: yup
.array(yup.string().trim().required("values can't be empty"))
.array(yup.string().trim().required("Values can't be empty"))
.optional(),
})
.required()
Expand Down
2 changes: 1 addition & 1 deletion packages/start-slicemachine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"bin": "./bin/start-slicemachine.js",
"dependencies": {
"@prismicio/mocks": "2.5.0",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/manager": "workspace:*",
"body-parser": "^1.20.3",
"chalk": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"devDependencies": {
"@msgpack/msgpack": "2.8.0",
"@playwright/test": "1.39.0",
"@prismicio/types-internal": "3.3.0-alpha.2",
"@prismicio/types-internal": "3.3.0",
"@slicemachine/manager": "workspace:*",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6236,9 +6236,9 @@ __metadata:
languageName: node
linkType: hard

"@prismicio/types-internal@npm:3.3.0-alpha.2":
version: 3.3.0-alpha.2
resolution: "@prismicio/types-internal@npm:3.3.0-alpha.2"
"@prismicio/types-internal@npm:3.3.0":
version: 3.3.0
resolution: "@prismicio/types-internal@npm:3.3.0"
dependencies:
monocle-ts: ^2.3.11
newtype-ts: ^0.3.5
Expand All @@ -6248,7 +6248,7 @@ __metadata:
fp-ts: ^2.11.8
io-ts: ^2.2.16
io-ts-types: ^0.5.16
checksum: 7439e4bdd456059fae8cd0759a7abb64b14ee35876bfbb84609e0bbacfb396eb23141a88fcf7c340ffe03f0367b2f01e76df8d39133961f921f0950c1267961a
checksum: 898dba5cfd61e428d117f12ec59aa7146920593068222d7d0b0f67f95e0a822ff52b930353ca194c4aee887762e8edad8a11460994479bfb193956104dabe9ff
languageName: node
linkType: hard

Expand Down Expand Up @@ -8980,7 +8980,7 @@ __metadata:
dependencies:
"@prismicio/mock": 0.2.0
"@prismicio/simulator": ^0.1.4
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/plugin-kit": "workspace:*"
"@types/common-tags": 1.8.1
Expand Down Expand Up @@ -9025,7 +9025,7 @@ __metadata:
dependencies:
"@prismicio/mock": 0.2.0
"@prismicio/simulator": ^0.1.4
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/plugin-kit": "workspace:*"
"@typescript-eslint/eslint-plugin": 5.55.0
Expand Down Expand Up @@ -9066,7 +9066,7 @@ __metadata:
dependencies:
"@prismicio/mock": 0.2.0
"@prismicio/simulator": ^0.1.4
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/plugin-kit": "workspace:*"
"@types/common-tags": 1.8.1
Expand Down Expand Up @@ -9108,7 +9108,7 @@ __metadata:
dependencies:
"@prismicio/mock": 0.2.0
"@prismicio/simulator": ^0.1.4
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/plugin-kit": "workspace:*"
"@sveltejs/kit": 2.0.0
Expand Down Expand Up @@ -9161,7 +9161,7 @@ __metadata:
dependencies:
"@msgpack/msgpack": 2.8.0
"@playwright/test": 1.39.0
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@slicemachine/manager": "workspace:*"
"@typescript-eslint/eslint-plugin": 7.17.0
"@typescript-eslint/parser": 7.17.0
Expand Down Expand Up @@ -9231,7 +9231,7 @@ __metadata:
"@prismicio/custom-types-client": 2.1.0
"@prismicio/mock": 0.2.0
"@prismicio/mocks": 2.5.0
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@segment/analytics-node": ^2.1.2
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/plugin-kit": "workspace:*"
Expand Down Expand Up @@ -9289,7 +9289,7 @@ __metadata:
dependencies:
"@prismicio/client": ^7.11.0
"@prismicio/mock": 0.3.7
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@types/common-tags": 1.8.1
"@types/fs-extra": 11.0.1
Expand Down Expand Up @@ -31227,7 +31227,7 @@ __metadata:
"@prismicio/mock": 0.3.3
"@prismicio/mocks": 2.5.0
"@prismicio/simulator": 0.1.4
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@radix-ui/react-hover-card": 1.0.6
"@radix-ui/react-tabs": 1.0.4
"@radix-ui/react-visually-hidden": 1.0.3
Expand Down Expand Up @@ -31705,7 +31705,7 @@ __metadata:
resolution: "start-slicemachine@workspace:packages/start-slicemachine"
dependencies:
"@prismicio/mocks": 2.5.0
"@prismicio/types-internal": 3.3.0-alpha.2
"@prismicio/types-internal": 3.3.0
"@size-limit/preset-small-lib": 8.2.4
"@slicemachine/manager": "workspace:*"
"@types/body-parser": 1.19.2
Expand Down
Loading