Skip to content

Commit a5752fc

Browse files
author
Joren Broekema
committed
fix(button): fix implicit form submission IE11 due to visibility hidden
1 parent 94818e4 commit a5752fc

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

packages/button/src/LionButton.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
7171
7272
:host .btn ::slotted(button) {
7373
position: absolute;
74-
visibility: hidden;
7574
}
7675
7776
.click-area {
@@ -111,6 +110,22 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
111110
fill: #adadad;
112111
}
113112
`,
113+
...(this.__isIE11() /* visibility hidden in IE11 breaks native button functionality */
114+
? [
115+
/* TODO: Make SR-only css mixin? */
116+
css`
117+
:host .btn ::slotted(button) {
118+
clip: rect(0, 0, 0, 0);
119+
}
120+
`,
121+
]
122+
: [
123+
css`
124+
:host .btn ::slotted(button) {
125+
visibility: hidden;
126+
}
127+
`,
128+
]),
114129
];
115130
}
116131

@@ -120,7 +135,6 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
120135
_button: () => {
121136
if (!this.constructor._button) {
122137
this.constructor._button = document.createElement('button');
123-
this.constructor._button.setAttribute('slot', '_button');
124138
this.constructor._button.setAttribute('tabindex', '-1');
125139
}
126140
return this.constructor._button.cloneNode();

packages/button/stories/index.stories.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,4 @@ storiesOf('Buttons|Button', module)
4747
</form></lion-form
4848
>
4949
`,
50-
)
51-
.add('Within another form', () => {
52-
const submitForm = () => console.log('hey');
53-
return html`
54-
<form id="form" @submit=${submitForm}>
55-
<h3>Details</h3>
56-
<input name="input1" />
57-
<input name="input2" />
58-
<input name="input3" />
59-
<lion-button>Submit</lion-button>
60-
</form>
61-
`;
62-
});
50+
);

0 commit comments

Comments
 (0)