Skip to content

Commit d388fe7

Browse files
committed
feat(QSelect, QBtnDropdown): Pass menu anchor props (anchor, self, offset), allow select options to shrink width quasarframework#5895
1 parent 7a4899b commit d388fe7

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

ui/src/components/btn-dropdown/QBtnDropdown.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default Vue.extend({
2626
cover: Boolean,
2727
persistent: Boolean,
2828
autoClose: Boolean,
29+
2930
menuAnchor: {
3031
type: String,
3132
default: 'bottom right'
@@ -34,6 +35,7 @@ export default Vue.extend({
3435
type: String,
3536
default: 'top right'
3637
},
38+
menuOffset: Array,
3739

3840
disableMainBtn: Boolean,
3941
disableDropdown: Boolean
@@ -77,6 +79,7 @@ export default Vue.extend({
7779
autoClose: this.autoClose,
7880
anchor: this.menuAnchor,
7981
self: this.menuSelf,
82+
offset: this.menuOffset,
8083
contentClass: this.contentClass,
8184
contentStyle: this.contentStyle,
8285
separateClosePopup: true

ui/src/components/btn-dropdown/QBtnDropdown.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"center left", "center middle", "center right",
8282
"bottom left", "bottom center", "bottom right"
8383
],
84+
"default": "bottom right",
8485
"examples": [ "top left", "bottom right" ],
8586
"category": "position"
8687
},
@@ -93,8 +94,17 @@
9394
"center left", "center middle", "center right",
9495
"bottom left", "bottom center", "bottom right"
9596
],
97+
"default": "top right",
9698
"examples": [ "top left", "bottom right" ],
9799
"category": "position"
100+
},
101+
102+
"menu-offset": {
103+
"type": "Array",
104+
"desc": "An array of two numbers to offset the menu horizontally and vertically in pixels",
105+
"examples": [ "[8, 8]", "[5, 10]" ],
106+
"category": "position",
107+
"addedIn": "v1.9.2"
98108
}
99109
},
100110

ui/src/components/select/QSelect.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ export default Vue.extend({
6161
default: null
6262
},
6363
optionsSelectedClass: String,
64-
optionsCover: Boolean,
6564
optionsSanitize: Boolean,
6665

66+
optionsCover: Boolean,
67+
68+
menuShrink: Boolean,
69+
menuAnchor: String,
70+
menuSelf: String,
71+
menuOffset: Array,
72+
6773
popupContentClass: String,
6874
popupContentStyle: [String, Array, Object],
6975

@@ -1031,8 +1037,11 @@ export default Vue.extend({
10311037
ref: 'menu',
10321038
props: {
10331039
value: this.menu,
1034-
fit: true,
1040+
fit: this.menuShrink !== true,
10351041
cover: this.optionsCover === true && this.noOptions !== true && this.useInput !== true,
1042+
anchor: this.menuAnchor,
1043+
self: this.menuSelf,
1044+
offset: this.menuOffset,
10361045
contentClass: this.menuContentClass,
10371046
contentStyle: this.popupContentStyle,
10381047
dark: this.isOptionsDark,

ui/src/components/select/QSelect.json

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,57 @@
119119
"category": "options"
120120
},
121121

122+
"options-sanitize": {
123+
"extends": "sanitize",
124+
"desc": "Force use of textContent instead of innerHTML to render options; Use it when the options might be unsafe (from user input); Does NOT apply when using 'option' slot!",
125+
"category": "options"
126+
},
127+
122128
"options-cover": {
123129
"type": "Boolean",
124130
"desc": "Expanded menu will cover the component (will not work along with 'use-input' prop for obvious reasons)",
125131
"category": "options"
126132
},
127133

128-
"options-sanitize": {
129-
"extends": "sanitize",
130-
"desc": "Force use of textContent instead of innerHTML to render options; Use it when the options might be unsafe (from user input); Does NOT apply when using 'option' slot!",
131-
"category": "options"
134+
"menu-shrink": {
135+
"type": "Boolean",
136+
"desc": "Allow the options list to be narrower than the field (only in menu mode)",
137+
"category": "options",
138+
"addedIn": "v1.9.2"
139+
},
140+
141+
"menu-anchor": {
142+
"type": "String",
143+
"desc": "Two values setting the starting position or anchor point of the options list relative to the field (only in menu mode)",
144+
"values": [
145+
"top left", "top middle", "top right",
146+
"center left", "center middle", "center right",
147+
"bottom left", "bottom center", "bottom right"
148+
],
149+
"examples": [ "top left", "bottom right" ],
150+
"category": "position",
151+
"addedIn": "v1.9.2"
152+
},
153+
154+
"menu-self": {
155+
"type": "String",
156+
"desc": "Two values setting the options list's own position relative to its target (only in menu mode)",
157+
"values": [
158+
"top left", "top middle", "top right",
159+
"center left", "center middle", "center right",
160+
"bottom left", "bottom center", "bottom right"
161+
],
162+
"examples": [ "top left", "bottom right" ],
163+
"category": "position",
164+
"addedIn": "v1.9.2"
165+
},
166+
167+
"menu-offset": {
168+
"type": "Array",
169+
"desc": "An array of two numbers to offset the options list horizontally and vertically in pixels (only in menu mode)",
170+
"examples": [ "[8, 8]", "[5, 10]" ],
171+
"category": "position",
172+
"addedIn": "v1.9.2"
132173
},
133174

134175
"popup-content-class": {

0 commit comments

Comments
 (0)