4444 </MenuItem >
4545 </MenuItems >
4646 </Menu >
47- <code class =" h-full flex-1 relative" >
47+ <code
48+ class =" flex-1 py-2px pr-2px pl-0 relative overflow-hidden"
49+ :style =" {height: 'calc(100% + 4px)'}"
50+ >
4851 <span
49- ref =" ghostLeft"
5052 class =" flex pl-12px inset-y-0 text-gray-600 absolute items-center pointer-events-none"
5153 data-cy =" selected-playground-method"
5254 >
5355 <span class =" text-gray-800" >cy</span >.<span class =" text-purple-500" >{{ selectorPlaygroundStore.method }}</span >(‘
5456 </span >
55- <span
56- ref =" ghostRight"
57- class =" font-medium left-[-9999px] absolute inline-block"
58- >{{ selector.replace(/\s/g, '  ; ') }}</span >
59- <span
60- class =" flex inset-y-0 text-gray-600 absolute items-center pointer-events-none"
61- :style =" {left: inputRightOffset + 'px'}"
62- >‘)</span >
6357 <input
64- ref =" copyText"
6558 v-model =" selector"
59+ autocapitalize =" none"
60+ autocorrect =" off"
61+ spellcheck =" false"
6662 data-cy =" playground-selector"
67- :style =" {paddingLeft: inputLeftOffset + 'px ', paddingRight: matcherWidth + 32 + 24 + 'px'}"
63+ :style =" {paddingLeft: leftOfInputText + 'ch ', paddingRight: widthOfMatchesHelperText + 'px'}"
6864 class =" border rounded-r-md font-medium h-full outline-none border-gray-200 w-full text-indigo-500 hocus-default overflow-ellipsis"
6965 :class =" {'hocus-default': selectorPlaygroundStore.isValid, 'hocus-error': !selectorPlaygroundStore.isValid}"
7066 >
67+ <span
68+ class =" flex inset-y-0 text-gray-600 absolute items-center pointer-events-none"
69+ :style =" {
70+ left: `${leftOffsetForClosingParens}ch`,
71+ }"
72+ >’)</span >
7173 <div
7274 ref =" match"
73- class =" border-l flex font-sans border-l-gray-200 my-6px px-16px inset-y-0 right-0 text-gray-600 absolute items-center"
75+ class =" bg-white border-l flex font-sans border-l-gray-200 my-6px px-16px inset-y-0 right-3px text-gray-600 absolute items-center"
7476 data-cy =" playground-num-elements"
7577 >
7678 <template v-if =" ! selectorPlaygroundStore .isValid " >
@@ -174,7 +176,19 @@ const selectorPlaygroundStore = useSelectorPlaygroundStore()
174176const match = ref <HTMLDivElement >()
175177const { width : matcherWidth } = useElementSize (match )
176178
177- const copyText = ref <HTMLInputElement >()
179+ // Text that is printed to the LEFT of the input
180+ const leftOfInputText = computed (() => {
181+ return (selectorPlaygroundStore .method === ' get' ? ' cy.get(‘' : ' cy.contains(’' ).length + 1
182+ })
183+
184+ const widthOfMatchesHelperText = computed (() => {
185+ // Arbitrary padding
186+ return matcherWidth .value + 32 + 24
187+ })
188+
189+ const leftOffsetForClosingParens = computed (() => {
190+ return leftOfInputText .value + selector .value .length
191+ })
178192
179193watch (() => selectorPlaygroundStore .method , () => {
180194 props .getAutIframe ().toggleSelectorHighlight (true )
@@ -199,23 +213,6 @@ const selector = computed({
199213 },
200214})
201215
202- const inputSize = useElementSize (copyText )
203-
204- // spooky
205- const ghostLeft = ref <HTMLSpanElement >()
206- const { width : ghostLeftWidth } = useElementSize (ghostLeft )
207- const inputLeftOffset = computed (() => ghostLeftWidth .value + 12 )
208-
209- const ghostRight = ref <HTMLSpanElement >()
210- const { width : ghostRightWidth } = useElementSize (ghostRight )
211- const inputRightOffset = computed (() => {
212- const leftOffset = inputLeftOffset .value
213- const combined = leftOffset + ghostRightWidth .value
214- const max = inputSize .width .value + leftOffset
215-
216- return combined <= max ? combined : max
217- })
218-
219216function setShowingHighlight () {
220217 selectorPlaygroundStore .setShowingHighlight (true )
221218 props .getAutIframe ().toggleSelectorHighlight (true )
0 commit comments