Skip to content

Commit 5db220d

Browse files
authored
refactor!: do not set primary theme on the CRUD new item button (#9817)
1 parent a0a016d commit 5db220d

25 files changed

+4
-5
lines changed

packages/crud/src/vaadin-crud-controllers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class ButtonSlotController extends SlotController {
4242
}
4343

4444
// Respect default theme attribute set by the Flow counterpart
45-
if (node === this.defaultNode && !node.hasAttribute('theme')) {
45+
if (node === this.defaultNode && this.theme && !node.hasAttribute('theme')) {
4646
node.setAttribute('theme', this.theme);
4747
}
4848

packages/crud/src/vaadin-crud-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export const CrudMixin = (superClass) =>
400400
this.addController(this._gridController);
401401

402402
// Init button controllers in `ready()` (not constructor) so that Flow can set `_noDefaultButtons`
403-
this._newButtonController = new ButtonSlotController(this, 'new', 'primary', this._noDefaultButtons);
403+
this._newButtonController = new ButtonSlotController(this, 'new', null, this._noDefaultButtons);
404404
this.addController(this._newButtonController);
405405

406406
this._headerController = new SlotController(this, 'header', 'h3', {

packages/crud/test/crud-buttons.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,13 @@ describe('crud buttons', () => {
747747
expect(button.textContent).to.equal('Add user');
748748
});
749749

750-
it('should set theme attribute of the new item button when marked as a default', async () => {
750+
it('should not set theme attribute on the new item button when marked as a default', async () => {
751751
button._isDefault = true;
752752

753753
crud.appendChild(button);
754754
await nextRender();
755755

756-
expect(button.getAttribute('theme')).to.equal('primary');
756+
expect(button.hasAttribute('theme')).to.be.false;
757757
});
758758

759759
it('should not change theme attribute of the new item button when marked as a default', async () => {

packages/crud/test/dom/__snapshots__/crud.test.snap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ snapshots["vaadin-crud host default"] =
221221
role="button"
222222
slot="new-button"
223223
tabindex="0"
224-
theme="primary"
225224
>
226225
New item
227226
</vaadin-button>
-11 Bytes
Loading
-9 Bytes
Loading
-1.68 KB
Loading
-1.68 KB
Loading
-1 Bytes
Loading
-9 Bytes
Loading

0 commit comments

Comments
 (0)