Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(group): prevent horizontal overflow in IE11 instead of wrapping #111

Merged
merged 2 commits into from Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vaadin-radio-group.html
Expand Up @@ -14,6 +14,9 @@
<style>
:host {
display: inline-flex;

/* Prevent horizontal overflow in IE 11 instead of wrapping radios */
max-width: 100%;
}

:host::before {
Expand All @@ -29,6 +32,9 @@
.vaadin-group-field-container {
display: flex;
flex-direction: column;

/* Prevent horizontal overflow in IE 11 instead of wrapping radios */
width: 100%;
}

[part="label"]:empty {
Expand Down
1 change: 1 addition & 0 deletions test/.eslintrc.json
Expand Up @@ -9,6 +9,7 @@
"gemini": false,
"sinon": false,
"MockInteractions": false,
"animationFrameFlush": false,
"flush": false
}
}
50 changes: 50 additions & 0 deletions test/vaadin-radio-group.html
Expand Up @@ -58,6 +58,25 @@
</template>
</test-fixture>

<test-fixture id="wrapping">
<template>
<vaadin-radio-group>
<vaadin-radio-button value="r_1">Radio button 1</vaadin-radio-button>
<vaadin-radio-button value="r_2">Radio button 2</vaadin-radio-button>
<vaadin-radio-button value="r_3">Radio button 3</vaadin-radio-button>
<vaadin-radio-button value="r_4">Radio button 4</vaadin-radio-button>
<vaadin-radio-button value="r_5">Radio button 5</vaadin-radio-button>
<vaadin-radio-button value="r_6">Radio button 6</vaadin-radio-button>
<vaadin-radio-button value="r_7">Radio button 7</vaadin-radio-button>
<vaadin-radio-button value="r_8">Radio button 8</vaadin-radio-button>
<vaadin-radio-button value="r_9">Radio button 9</vaadin-radio-button>
<vaadin-radio-button value="r_10">Radio button 10</vaadin-radio-button>
<vaadin-radio-button value="r_11">Radio button 11</vaadin-radio-button>
<vaadin-radio-button value="r_12">Radio button 12</vaadin-radio-button>
</vaadin-radio-group>
</template>
</test-fixture>

<script>
describe('vaadin-radio-group', () => {

Expand Down Expand Up @@ -524,5 +543,36 @@
});
});
});

describe('vaadin-radio-group wrapping', () => {
let vaadinRadioButtonGroup;

beforeEach((done) => {
vaadinRadioButtonGroup = fixture('wrapping');
vaadinRadioButtonGroup._observer.flush();
animationFrameFlush(done);
});

it('should not overflow horizontally', () => {
const parentWidth = vaadinRadioButtonGroup.parentElement.offsetWidth;
expect(vaadinRadioButtonGroup.offsetWidth).to.be.lte(parentWidth);
expect(
vaadinRadioButtonGroup
.shadowRoot
.querySelector('[part~="group-field"]')
.offsetWidth
).to.be.lte(parentWidth);
});

it('should wrap radio-buttons', () => {
const radios = Array.from(vaadinRadioButtonGroup.children);
const {top: firstTop, left: firstLeft} = radios[0].getBoundingClientRect();
const wrappedRadios = Array.from(radios)
.slice(1)
.filter(radio => radio.getBoundingClientRect().top > firstTop);
expect(wrappedRadios).to.not.be.empty;
expect(wrappedRadios[0].getBoundingClientRect().left).to.equal(firstLeft);
});
});
</script>
</body>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions test/visual/test.js
Expand Up @@ -24,6 +24,13 @@ gemini.suite('vaadin-radio-button', function(rootSuite) {
});
});
});

gemini.suite(`wrapping-tests-${theme}`, function(suite) {
suite
.setUrl(`wrapping.html?theme=${theme}`)
.setCaptureElements('#wrapping-tests')
.capture('wrapping');
});
});

});
25 changes: 25 additions & 0 deletions test/visual/wrapping.html
@@ -0,0 +1,25 @@
<!DOCTYPE html>

<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script>
const theme = window.location.search.replace(/.*theme=(\w+).*/, '$1') || 'lumo';
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-radio-button.html">`);
document.write(`<link rel="import" href="../../theme/${theme}/vaadin-radio-group.html">`);
</script>
</head>

<body>

<div id="wrapping-tests" style="width: 320px; padding: 6px;">
<vaadin-radio-group label="Choose a number">
<vaadin-radio-button value="1">Radio button 1</vaadin-radio-button>
<vaadin-radio-button value="2">Radio button 2</vaadin-radio-button>
<vaadin-radio-button value="3">Radio button 3</vaadin-radio-button>
<vaadin-radio-button value="4">Radio button 4</vaadin-radio-button>
</vaadin-radio-group>
</div>

</body>