Skip to content

Commit 198ba78

Browse files
authored
Merge pull request #440 from sronveaux/fix-geocoder-width
Fix header title getting truncated and change geocoder flex width behaviour
2 parents 0fb9d7f + d717567 commit 198ba78

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

app-starter/components/AppHeader.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
<!-- slot to inject components after the title text -->
1313
<slot name="wgu-tb-after-title"></slot>
1414

15-
<v-spacer></v-spacer>
16-
1715
<!-- slot to inject components before the auto-generated buttons (by config) -->
1816
<slot name="wgu-tb-before-auto-buttons"></slot>
1917

docs/module-configuration.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ Module identifier: `wgu-geocoder`
4646

4747
| Property | Meaning | Example |
4848
|--------------------|:---------:|---------|
49-
| rounded | Adds a border radius to the input. | `"rounded": true` |
49+
| width | The width of the text input field. | `"width": 400` |
50+
| minWidth | The minimum width of the text input field. Only applies if the `width` property is not defined. Defaults to `175` | `"minWidth": 175` |
51+
| maxWidth | The maximum width of the text input field. Only applies if the `width` property is not defined. Defaults to `300` | `"maxWidth": 300` |
52+
| rounded | Adds a border radius to the text input field. | `"rounded": true` |
5053
| autofocus | Enables autofocus | `"autofocus": true` |
5154
| clearable | Add input clear functionality. | `"clearable": true` |
5255
| persistentHint | Forces hint to always be visible. | `"persistentHint": true` |

src/components/geocoder/Geocoder.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
class="wgu-geocoder-combo wgu-solo-field"
66
variant="outlined"
77
density="compact"
8-
width="320"
8+
:width="width"
9+
:min-width="width ? undefined : minWidth"
10+
:max-width="width ? undefined : maxWidth"
911
:list-props="{ nav: true, density: 'compact' }"
1012
:color="isPrimaryDarkWithLightTheme ? 'white' : 'accent'"
1113
:theme="isDarkTheme ? 'dark' : 'light'"
@@ -47,6 +49,9 @@ export default {
4749
name: 'wgu-geocoder-input',
4850
props: {
4951
icon: { type: String, required: false, default: 'md:search' },
52+
width: { type: Number, required: false, default: undefined },
53+
minWidth: { type: Number, required: false, default: 175 },
54+
maxWidth: { type: Number, required: false, default: 300 },
5055
rounded: { type: Boolean, required: false, default: true },
5156
autofocus: { type: Boolean, required: false, default: true },
5257
clearable: { type: Boolean, required: false, default: true },

tests/unit/specs/components/geocoder/Geocoder.spec.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ describe('geocoder/Geocoder.vue', () => {
4444

4545
it('has correct default props', () => {
4646
expect(vm.icon).to.equal('md:search');
47+
expect(vm.width).to.be.undefined;
48+
expect(vm.minWidth).to.equal(175);
49+
expect(vm.maxWidth).to.equal(300);
4750
expect(vm.rounded).to.be.true;
4851
expect(vm.autofocus).to.be.true;
4952
expect(vm.clearable).to.be.true;
@@ -137,6 +140,61 @@ describe('geocoder/Geocoder.vue', () => {
137140
});
138141
});
139142

143+
describe('configured width', () => {
144+
describe('width property is not defined', () => {
145+
beforeEach(() => {
146+
const moduleProps = {
147+
target: 'toolbar',
148+
minWidth: 50,
149+
maxWidth: 100
150+
};
151+
152+
comp = createWrapper({ props: moduleProps });
153+
vm = comp.vm;
154+
});
155+
156+
it('combobox width is undefined', () => {
157+
const comboBox = comp.findComponent({ name: 'v-combobox' });
158+
159+
expect(comboBox.props('width')).to.be.undefined;
160+
});
161+
162+
it('combobox maxWidth and minWidth are assigned correctly', () => {
163+
const comboBox = comp.findComponent({ name: 'v-combobox' });
164+
165+
expect(comboBox.props('maxWidth')).to.equal(100);
166+
expect(comboBox.props('minWidth')).to.equal(50);
167+
});
168+
});
169+
170+
describe('width property is defined', () => {
171+
beforeEach(() => {
172+
const moduleProps = {
173+
target: 'toolbar',
174+
width: 75,
175+
minWidth: 50,
176+
maxWidth: 100
177+
};
178+
179+
comp = createWrapper({ props: moduleProps });
180+
vm = comp.vm;
181+
});
182+
183+
it('combobox maxWidth and minWidth are undefined', () => {
184+
const comboBox = comp.findComponent({ name: 'v-combobox' });
185+
186+
expect(comboBox.props('maxWidth')).to.be.undefined;
187+
expect(comboBox.props('minWidth')).to.be.undefined;
188+
});
189+
190+
it('combobox width is assigned correctly', () => {
191+
const comboBox = comp.findComponent({ name: 'v-combobox' });
192+
193+
expect(comboBox.props('width')).to.equal(75);
194+
});
195+
});
196+
});
197+
140198
describe('methods - search', () => {
141199
let map;
142200
let axiosMock;

0 commit comments

Comments
 (0)