Commit 2f5e1192 authored by Enrique Alcantara's avatar Enrique Alcantara

Implement select on focus behavior

parent c2e9b68e
<script> <script>
import { GlPopover, GlFormInputGroup, GlFormInput } from '@gitlab/ui'; import { GlPopover, GlFormInputGroup } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
...@@ -8,7 +8,6 @@ export default { ...@@ -8,7 +8,6 @@ export default {
GlPopover, GlPopover,
GlFormInputGroup, GlFormInputGroup,
ClipboardButton, ClipboardButton,
GlFormInput,
}, },
inject: ['pushToCreateProjectCommand', 'workingWithProjectsHelpPath'], inject: ['pushToCreateProjectCommand', 'workingWithProjectsHelpPath'],
props: { props: {
...@@ -39,14 +38,13 @@ export default { ...@@ -39,14 +38,13 @@ export default {
</label> </label>
</p> </p>
<p> <p>
<gl-form-input-group> <gl-form-input-group
<gl-form-input id="push-to-create-tip"
id="push-to-create-tip" :value="pushToCreateProjectCommand"
class="monospace js-select-on-focus" readonly
readonly select-on-click
:value="pushToCreateProjectCommand" :aria-label="$options.i18n.commandInputAriaLabel"
:aria-label="$options.i18n.commandInputAriaLabel" >
/>
<template #append> <template #append>
<clipboard-button <clipboard-button
:text="pushToCreateProjectCommand" :text="pushToCreateProjectCommand"
......
import { GlPopover, GlFormInputGroup, GlFormInput } from '@gitlab/ui'; import { GlPopover, GlFormInputGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import NewProjectPushTipPopover from '~/projects/experiment_new_project_creation/components/new_project_push_tip_popover.vue'; import NewProjectPushTipPopover from '~/projects/experiment_new_project_creation/components/new_project_push_tip_popover.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
...@@ -11,7 +11,7 @@ describe('New project push tip popover', () => { ...@@ -11,7 +11,7 @@ describe('New project push tip popover', () => {
const findPopover = () => wrapper.findComponent(GlPopover); const findPopover = () => wrapper.findComponent(GlPopover);
const findClipboardButton = () => wrapper.findComponent(ClipboardButton); const findClipboardButton = () => wrapper.findComponent(ClipboardButton);
const findFormInput = () => wrapper.findComponent(GlFormInput); const findFormInput = () => wrapper.findComponent(GlFormInputGroup);
const findHelpLink = () => wrapper.find('a'); const findHelpLink = () => wrapper.find('a');
const findTarget = () => document.getElementById(targetId); const findTarget = () => document.getElementById(targetId);
...@@ -49,11 +49,14 @@ describe('New project push tip popover', () => { ...@@ -49,11 +49,14 @@ describe('New project push tip popover', () => {
}); });
it('renders a readonly form input with the push to create command', () => { it('renders a readonly form input with the push to create command', () => {
expect(findFormInput().attributes()).toMatchObject({ expect(findFormInput().props()).toMatchObject({
value: pushToCreateProjectCommand, value: pushToCreateProjectCommand,
readonly: '', selectOnClick: true,
});
expect(findFormInput().attributes()).toMatchObject({
'aria-label': 'Push project from command line',
readonly: 'readonly',
}); });
expect(findFormInput().classes()).toContain('js-select-on-focus');
}); });
it('allows copying the push command using the clipboard button', () => { it('allows copying the push command using the clipboard button', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment