Fix popup overflow

This commit is contained in:
the1812 2021-11-14 16:31:40 +08:00
parent ed4410c6aa
commit e33a2c928d
2 changed files with 16 additions and 3 deletions

View File

@ -57,6 +57,11 @@ export default Vue.extend({
type: Boolean,
default: false,
},
maxColumnCount: {
type: Number,
// TODO: , , 2
default: 2,
},
},
data() {
const { componentName } = this.options
@ -77,7 +82,10 @@ export default Vue.extend({
methods: {
updateColumnsCount() {
const element = this.$el as HTMLElement
const columns = Math.ceil(Object.keys(this.options.switches).length / 12)
const columns = Math.min(
Math.ceil(Object.keys(this.options.switches).length / 12),
this.maxColumnCount,
)
element.style.setProperty('--columns', columns.toString())
},
isDim(name: string) {
@ -87,7 +95,7 @@ export default Vue.extend({
})
</script>
<style lang="scss" scoped>
<style lang="scss">
@import 'common';
.switch-options {
position: relative;
@ -108,6 +116,7 @@ export default Vue.extend({
white-space: nowrap;
padding: 4px;
display: grid;
width: max-content;
grid-template-columns: repeat(var(--columns), auto);
border-radius: 5px;
border: 1px solid #8882;

View File

@ -31,7 +31,7 @@
@previous-item="previousItem($event, index)"
@next-item="nextItem($event, index)"
@delete-item="onDeleteItem($event, index)"
@action="(index === actions.length - 1) && onClearHistory()"
@action="(index === actions.length - 1) && onClearHistory(); onAction(a)"
/>
</div>
<div v-if="!isHistory" class="launch-bar-action-list">
@ -52,6 +52,7 @@
@previous-item="previousItem($event, index)"
@next-item="nextItem($event, index)"
@delete-item="onDeleteItem($event, index)"
@action="onAction(a)"
/>
</div>
</div>
@ -227,6 +228,9 @@ export default Vue.extend({
this.focus()
this.getActions()
},
onAction() {
// this.focus()
},
focus() {
this.$refs.input.focus()
},