Expanding the focus behaviour to more component types in the builder. Minor fix for cypress test
This commit is contained in:
parent
8a189f3451
commit
663a4ee7c7
|
@ -13,6 +13,10 @@
|
||||||
export let size = "M"
|
export let size = "M"
|
||||||
export let active = false
|
export let active = false
|
||||||
export let fullWidth = false
|
export let fullWidth = false
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
|
let focus = false
|
||||||
|
$: focus = autofocus
|
||||||
|
|
||||||
function longPress(element) {
|
function longPress(element) {
|
||||||
if (!longPressable) return
|
if (!longPressable) return
|
||||||
|
@ -44,9 +48,16 @@
|
||||||
class:fullWidth
|
class:fullWidth
|
||||||
class="spectrum-ActionButton spectrum-ActionButton--size{size}"
|
class="spectrum-ActionButton spectrum-ActionButton--size{size}"
|
||||||
class:active
|
class:active
|
||||||
|
class:is-focused={focus}
|
||||||
{disabled}
|
{disabled}
|
||||||
on:longPress
|
on:longPress
|
||||||
on:click|preventDefault
|
on:click|preventDefault
|
||||||
|
on:focus={() => {
|
||||||
|
focus = true
|
||||||
|
}}
|
||||||
|
on:blur={() => {
|
||||||
|
focus = false
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{#if longPressable}
|
{#if longPressable}
|
||||||
<svg
|
<svg
|
||||||
|
@ -80,4 +91,10 @@
|
||||||
.active svg {
|
.active svg {
|
||||||
color: var(--spectrum-global-color-blue-600);
|
color: var(--spectrum-global-color-blue-600);
|
||||||
}
|
}
|
||||||
|
button.is-focused {
|
||||||
|
border-color: var(
|
||||||
|
--spectrum-textfield-m-border-color-down,
|
||||||
|
var(--spectrum-alias-border-color-mouse-focus)
|
||||||
|
);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -56,8 +56,12 @@
|
||||||
bind:this={comboInput}
|
bind:this={comboInput}
|
||||||
{id}
|
{id}
|
||||||
type="text"
|
type="text"
|
||||||
on:focus={() => (focus = true)}
|
on:focus={() => {
|
||||||
on:blur={() => (focus = false)}
|
focus = true
|
||||||
|
}}
|
||||||
|
on:blur={() => {
|
||||||
|
focus = false
|
||||||
|
}}
|
||||||
on:change={onType}
|
on:change={onType}
|
||||||
value={value || ""}
|
value={value || ""}
|
||||||
placeholder={placeholder || ""}
|
placeholder={placeholder || ""}
|
||||||
|
|
|
@ -118,20 +118,14 @@ filterTests(['all'], () => {
|
||||||
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
||||||
.should("have.class", "is-focused").within(() => {
|
.should("have.class", "is-focused").within(() => {
|
||||||
cy.get("input").should(($input) => {
|
cy.get("input").should(($input) => {
|
||||||
expect($input).to.have.length(1)
|
|
||||||
inputClasses = Cypress.$($input).attr('class')
|
inputClasses = Cypress.$($input).attr('class')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
cy.focused().then(($focused) => {
|
|
||||||
const focusedClasses = Cypress.$($focused).attr('class')
|
|
||||||
expect(inputClasses).to.equal(focusedClasses)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const testFieldFocusOnCreate = (componentLabel) => {
|
const testFieldFocusOnCreate = (componentLabel) => {
|
||||||
let inputClasses
|
let inputClasses
|
||||||
|
cy.log("Adding: " + componentLabel)
|
||||||
cy.addComponent("Form", componentLabel).then((componentId) => {
|
cy.addComponent("Form", componentLabel).then((componentId) => {
|
||||||
|
|
||||||
refocusTest(componentId)
|
refocusTest(componentId)
|
||||||
|
@ -139,15 +133,10 @@ filterTests(['all'], () => {
|
||||||
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
||||||
.should("have.class", "is-focused").within(() => {
|
.should("have.class", "is-focused").within(() => {
|
||||||
cy.get("input").should(($input) => {
|
cy.get("input").should(($input) => {
|
||||||
expect($input).to.have.length(1)
|
|
||||||
inputClasses = Cypress.$($input).attr('class')
|
inputClasses = Cypress.$($input).attr('class')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
cy.focused().then(($focused) => {
|
|
||||||
const focusedClasses = Cypress.$($focused).attr('class')
|
|
||||||
expect(inputClasses).to.equal(focusedClasses)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentTypeLabels.forEach( testFieldFocusOnCreate )
|
componentTypeLabels.forEach( testFieldFocusOnCreate )
|
||||||
|
|
|
@ -425,8 +425,10 @@ export const getFrontendStore = () => {
|
||||||
state.currentView = "component"
|
state.currentView = "component"
|
||||||
state.selectedComponentId = componentInstance._id
|
state.selectedComponentId = componentInstance._id
|
||||||
|
|
||||||
const focusSetting = definition.settings.filter((setting) => { return setting.required })
|
const focusSetting = definition.settings.filter(setting => {
|
||||||
const mappedSettings = focusSetting.map((setting) => {
|
return setting.required
|
||||||
|
})
|
||||||
|
const mappedSettings = focusSetting.map(setting => {
|
||||||
return {
|
return {
|
||||||
key: setting.key,
|
key: setting.key,
|
||||||
target: state.selectedComponentId,
|
target: state.selectedComponentId,
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
store.update(state => ({
|
store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
builderFocus :
|
builderFocus :
|
||||||
[{...data}]
|
[...data]
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Client sent unknown event type: ${type}`)
|
console.warn(`Client sent unknown event type: ${type}`)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let maxIconsPerPage = 30
|
export let maxIconsPerPage = 30
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
let searchTerm = ""
|
let searchTerm = ""
|
||||||
let selectedLetter = "A"
|
let selectedLetter = "A"
|
||||||
|
@ -117,7 +118,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={buttonAnchor}>
|
<div bind:this={buttonAnchor}>
|
||||||
<ActionButton on:click={dropdown.show}>{displayValue}</ActionButton>
|
<ActionButton on:click={dropdown.show} {autofocus}>
|
||||||
|
{displayValue}
|
||||||
|
</ActionButton>
|
||||||
</div>
|
</div>
|
||||||
<Popover bind:this={dropdown} on:open={setSelectedUI} anchor={buttonAnchor}>
|
<Popover bind:this={dropdown} on:open={setSelectedUI} anchor={buttonAnchor}>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
export let bindings
|
export let bindings
|
||||||
|
export let autofocus
|
||||||
|
|
||||||
$: urlOptions = $store.screens
|
$: urlOptions = $store.screens
|
||||||
.map(screen => screen.routing?.route)
|
.map(screen => screen.routing?.route)
|
||||||
|
@ -16,4 +17,5 @@
|
||||||
on:change
|
on:change
|
||||||
options={urlOptions}
|
options={urlOptions}
|
||||||
appendBindingsAsOptions={false}
|
appendBindingsAsOptions={false}
|
||||||
|
{autofocus}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -201,7 +201,6 @@
|
||||||
class="components-pane"
|
class="components-pane"
|
||||||
use:clickOutside={() => {
|
use:clickOutside={() => {
|
||||||
if ($store?.builderFocus) {
|
if ($store?.builderFocus) {
|
||||||
console.log($store?.builderFocus)
|
|
||||||
const otherSettings = $store?.builderFocus?.filter(field => {
|
const otherSettings = $store?.builderFocus?.filter(field => {
|
||||||
return field.location !== "component_settings"
|
return field.location !== "component_settings"
|
||||||
})
|
})
|
||||||
|
|
|
@ -1034,7 +1034,8 @@
|
||||||
{
|
{
|
||||||
"type": "icon",
|
"type": "icon",
|
||||||
"label": "Icon",
|
"label": "Icon",
|
||||||
"key": "icon"
|
"key": "icon",
|
||||||
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
|
|
|
@ -34,11 +34,13 @@
|
||||||
<span
|
<span
|
||||||
class="showMe spectrum-Link"
|
class="showMe spectrum-Link"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
builderStore.actions.setFocus({
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
key: "url",
|
key: "url",
|
||||||
target: $component.id,
|
target: $component.id,
|
||||||
})
|
},
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Show me
|
Show me
|
||||||
|
|
|
@ -28,14 +28,29 @@
|
||||||
/>
|
/>
|
||||||
{:else if $builderStore.inBuilder}
|
{:else if $builderStore.inBuilder}
|
||||||
<div use:styleable={styles}>
|
<div use:styleable={styles}>
|
||||||
<Placeholder />
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Add the <mark>Icon</mark> in the settings menu
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
|
location: "component_settings",
|
||||||
|
key: "icon",
|
||||||
|
target: $component.id,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
.hoverable:hover {
|
.hoverable:hover {
|
||||||
color: var(--spectrum-alias-icon-color-selected-hover) !important;
|
color: var(--spectrum-alias-icon-color-selected-hover) !important;
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
<span
|
<span
|
||||||
class="showMe spectrum-Link"
|
class="showMe spectrum-Link"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
builderStore.actions.setFocus({
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
key: "url",
|
key: "url",
|
||||||
target: $component.id,
|
target: $component.id,
|
||||||
})
|
},
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Show me
|
Show me
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
<span
|
<span
|
||||||
class="showMe spectrum-Link"
|
class="showMe spectrum-Link"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
builderStore.actions.setFocus({
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
key: "value",
|
key: "value",
|
||||||
target: $component.id,
|
target: $component.id,
|
||||||
})
|
},
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Show me
|
Show me
|
||||||
|
|
|
@ -15,16 +15,27 @@
|
||||||
<div use:styleable={$component.styles}>
|
<div use:styleable={$component.styles}>
|
||||||
<Placeholder>
|
<Placeholder>
|
||||||
<div slot="content">
|
<div slot="content">
|
||||||
Use the settings panel to select a <mark>Provider</mark> and start
|
Use the settings panel start building your chart
|
||||||
building your chart
|
|
||||||
<span
|
<span
|
||||||
class="showMe spectrum-Link"
|
class="showMe spectrum-Link"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
builderStore.actions.setFocus({
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
key: "dataProvider",
|
key: "dataProvider",
|
||||||
target: $component.id,
|
target: $component.id,
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
location: "component_settings",
|
||||||
|
key: "valueColumns",
|
||||||
|
target: $component.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: "component_settings",
|
||||||
|
key: "dataColumns",
|
||||||
|
target: $component.id,
|
||||||
|
},
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Show me
|
Show me
|
||||||
|
|
|
@ -84,11 +84,13 @@
|
||||||
<span
|
<span
|
||||||
class="showMe spectrum-Link"
|
class="showMe spectrum-Link"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
builderStore.actions.setFocus({
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
key: "field",
|
key: "field",
|
||||||
target: $component.id,
|
target: $component.id,
|
||||||
})
|
},
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Show me
|
Show me
|
||||||
|
|
|
@ -78,7 +78,7 @@ const createBuilderStore = () => {
|
||||||
},
|
},
|
||||||
setFocus: data => {
|
setFocus: data => {
|
||||||
window.parent.postMessage({ type: "builder-focus", data })
|
window.parent.postMessage({ type: "builder-focus", data })
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...store,
|
...store,
|
||||||
|
|
Loading…
Reference in New Issue