Skip to content

Commit 4e9f338

Browse files
authored
Merge branch 'next' into fix/fix-type-error-in-text-field-component
2 parents 8710727 + 5446e07 commit 4e9f338

File tree

9 files changed

+141
-58
lines changed

9 files changed

+141
-58
lines changed

.changeset/empty-scissors-rest.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@soramitsu-ui/ui': patch
3+
---
4+
5+
**fix**: (`SDropdown`) don't render label when it is absent, close #448

.changeset/olive-chicken-cry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@soramitsu-ui/ui': patch
3+
---
4+
5+
**fix**: (`SSelectBase`) pass `z-index: 10` to the popper wrapper, fix #430

packages/ui/cypress/component/SSelect.spec.cy.ts renamed to packages/ui/cypress/component/Select.spec.cy.ts

+53-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mount } from '@cypress/vue'
22
import { config } from '@vue/test-utils'
3-
import { SSelect, SSelectBase, SSelectButton, SSelectInput, SDropdown, SelectSize } from '@/lib'
3+
import { SSelect, SSelectBase, SSelectButton, SSelectInput, SDropdown, SelectSize, STextField } from '@/lib'
44

55
const SIZES = [SelectSize.Sm, SelectSize.Md, SelectSize.Lg, SelectSize.Xl]
66

@@ -14,6 +14,8 @@ after(() => {
1414
config.global.stubs = {}
1515
})
1616

17+
const findBtnLabel = () => cy.get('.s-select-btn__label')
18+
1719
it('Gallery - Dropdown', () => {
1820
mount({
1921
setup() {
@@ -276,3 +278,53 @@ it('SDropdown - show/hide by clicks', () => {
276278
cy.contains('Label').click()
277279
cy.contains('OPTION').should('not.be.visible')
278280
})
281+
282+
it(`SDropdown - when value is selected and label is not provided, then label is not rendered`, () => {
283+
mount({
284+
setup() {
285+
const showLabel = ref(true)
286+
const label = computed(() => (showLabel.value ? 'Choice' : ''))
287+
return {
288+
options: [{ label: 'Pizza', value: 'pizza' }],
289+
showLabel,
290+
label,
291+
}
292+
},
293+
template: `
294+
<input v-model="showLabel" type="checkbox"> Show label
295+
296+
<SDropdown
297+
v-bind="{ options, modelValue: 'pizza', label }"
298+
/>
299+
`,
300+
})
301+
302+
findBtnLabel().should('have.text', 'Choice:')
303+
cy.get('input').click().should('not.be.checked')
304+
findBtnLabel().should('not.exist')
305+
})
306+
307+
it('SSelectDropdown overlaps STextField', () => {
308+
mount({
309+
components: { STextField },
310+
setup() {
311+
return {
312+
options: [
313+
{ label: 'one', value: 1 },
314+
{ label: 'two', value: 2 },
315+
],
316+
}
317+
},
318+
template: `
319+
<div class="m-4 space-y-4">
320+
<SDropdown label="I am top" v-bind="{ options }" />
321+
<STextField placeholder="I am bottom" />
322+
</div>
323+
`,
324+
})
325+
326+
cy.contains('I am top').click()
327+
cy.contains('two')
328+
// trying to click to ensure the element is not covered by anything
329+
.click()
330+
})

packages/ui/etc/api/ui.api.md

+53-48
Large diffs are not rendered by default.

packages/ui/src/components/Popover/SPopover.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default /* @__PURE__ */ defineComponent({
235235
} else if (nodes.length === 1) {
236236
;[popper] = nodes
237237
} else {
238-
throw new Error('"popper" slot should return either nothing either the only 1 element')
238+
throw new Error('"popper" slot should return either nothing or the only 1 element')
239239
}
240240
}
241241

packages/ui/src/components/Popover/SPopoverWrappedTransition.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { mergeProps } from 'vue'
99
import { useWrappedTransitionVisibility } from './util'
1010
import { usePopoverApi } from './api'
1111
12-
interface Props {
13-
eager?: boolean
14-
}
15-
16-
const props = withDefaults(defineProps<Props>(), {
17-
eager: false,
12+
const props = defineProps({
13+
eager: Boolean,
14+
wrapperAttrs: {
15+
type: Object,
16+
default: null,
17+
},
1818
})
1919
2020
const api = usePopoverApi()
@@ -46,6 +46,7 @@ onScopeDispose(() => {
4646
v-if="wrapperIf"
4747
v-show="wrapperShow"
4848
ref="wrapper"
49+
v-bind="wrapperAttrs"
4950
>
5051
<Transition
5152
v-bind="mergeProps($attrs, transitionProps)"

packages/ui/src/components/Select/SDropdown.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@ const props = defineProps<{
1515
}>()
1616
1717
const buttonType = computed(() => (props.inline ? SelectButtonType.Inline : SelectButtonType.Default))
18+
19+
const slots = useSlots()
20+
21+
function isThereLabelSlot() {
22+
return !!slots.label
23+
}
1824
</script>
1925

2026
<template>
2127
<SSelectBase v-bind="{ ...$attrs, ...$props } as any">
2228
<template #control>
2329
<SSelectButton :type="buttonType">
24-
<template #label="binding">
30+
<template
31+
v-if="isThereLabelSlot() || label"
32+
#label="binding"
33+
>
2534
<slot
2635
name="label"
2736
v-bind="binding"

packages/ui/src/components/Select/SSelectBase.vue

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ provide(SELECT_API_KEY, api)
9797
<SPopoverWrappedTransition
9898
name="s-select-dropdown-transition"
9999
eager
100+
:wrapper-attrs="{ 'class': 'z-10' }"
100101
>
101102
<slot name="dropdown" />
102103
</SPopoverWrappedTransition>

packages/ui/src/components/Select/SSelectButton.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function typography(): string {
3939
return 'sora-tpg-p4'
4040
}
4141
}
42+
43+
const slots = useSlots()
4244
</script>
4345

4446
<template>
@@ -55,7 +57,10 @@ function typography(): string {
5557
]"
5658
@click="toggle"
5759
>
58-
<span class="s-select-btn__label">
60+
<span
61+
v-if="!!slots.label || api.label"
62+
class="s-select-btn__label"
63+
>
5964
<slot
6065
name="label"
6166
v-bind="api"

0 commit comments

Comments
 (0)