Skip to content

Commit e5d886c

Browse files
committed
fix(foxy-filter-attribute-form): hide Create button when filter query is empty
1 parent 6ca91d6 commit e5d886c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/elements/public/FilterAttributeForm/FilterAttributeForm.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ describe('FilterAttributeForm', () => {
140140
expect(element.hiddenSelector.matches('filter-name', true)).to.be.false;
141141
});
142142

143-
it('hides action if filter query is empty and attribute is not created yet', async () => {
143+
it('hides action when appropriate', async () => {
144144
const layout = html`<foxy-filter-attribute-form></foxy-filter-attribute-form>`;
145145
const element = await fixture<Form>(layout);
146146

147147
expect(element.hiddenSelector.matches('action', true)).to.be.true;
148148
element.data = await getTestData('./hapi/store_attributes/0');
149149
expect(element.hiddenSelector.matches('action', true)).to.be.false;
150150
element.edit({ value: '' });
151-
expect(element.hiddenSelector.matches('action', true)).to.be.false;
151+
expect(element.hiddenSelector.matches('action', true)).to.be.true;
152152
});
153153

154154
it('uses fixed visibility and attribute name when creating a resource', async () => {

src/elements/public/FilterAttributeForm/FilterAttributeForm.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ export class FilterAttributeForm extends Base<Data> {
6060
const constructor = this.constructor as typeof FilterAttributeForm;
6161
const filterQuery = this.__getValueParam(constructor.filterQueryKey);
6262
const hasData = !!this.data;
63+
const hasValue = !!this.form.value;
6364

6465
if (!hasData) alwaysHidden.push('filter-name');
65-
if (!filterQuery && !hasData) alwaysHidden.push('action');
66+
if (!hasValue || (!filterQuery && !hasData)) alwaysHidden.push('action');
6667

6768
return new BooleanSelector(`${alwaysHidden.join(' ')} ${super.hiddenSelector}`.trim());
6869
}

0 commit comments

Comments
 (0)