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

Resize plans properly #7597

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion e2e/tests/visual-a11y/planning.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,29 @@ test.describe('Visual - Planning', () => {
name: 'Plan Visual Test',
json: examplePlanSmall2
});

await setBoundsToSpanAllActivities(page, examplePlanSmall2, plan.url);
await percySnapshot(page, `Plan View (theme: ${theme})`);
});

test('Resize Plan View @2p', async ({ browser, theme }) => {
// need to set viewport to null to allow for resizing
const newContext = await browser.newContext({
viewport: null
});
const newPage = await newContext.newPage();

await newPage.goto(VISUAL_URL, { waitUntil: 'domcontentloaded' });
const plan = await createPlanFromJSON(newPage, {
name: 'Plan Visual Test',
json: examplePlanSmall2
});

await setBoundsToSpanAllActivities(newPage, examplePlanSmall2, plan.url);
// resize the window
await newPage.setViewportSize({ width: 800, height: 600 });
await percySnapshot(newPage, `Plan View resized (theme: ${theme})`);
});

test('Plan View w/ draft status', async ({ page, theme }) => {
const plan = await createPlanFromJSON(page, {
name: 'Plan Visual Test (Draft)',
Expand Down
21 changes: 12 additions & 9 deletions src/ui/components/TimeSystemAxis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@
},
setup() {
const axisHolder = ref(null);
const { size, startObserving } = useResizeObserver();
const { size: containerSize, startObserving } = useResizeObserver();
onMounted(() => {
startObserving(axisHolder.value);
});
return {
containerSize: size
axisHolder,
containerSize
};
},
watch: {
Expand All @@ -95,16 +96,19 @@
contentHeight() {
this.updateNowMarker();
},
containerSize() {
this.resize();
containerSize: {
handler() {
this.resize();

Check warning on line 101 in src/ui/components/TimeSystemAxis.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/components/TimeSystemAxis.vue#L101

Added line #L101 was not covered by tests
},
deep: true
}
},
mounted() {
if (this.renderingEngine === 'svg') {
this.useSVG = true;
}

this.container = select(this.$refs.axisHolder);
this.container = select(this.axisHolder);
this.svgElement = this.container.append('svg:svg');
// draw x axis with labels. CSS is used to position them.
this.axisElement = this.svgElement
Expand All @@ -122,7 +126,7 @@
},
methods: {
resize() {
if (this.$refs.axisHolder.clientWidth !== this.width) {
if (this.axisHolder.clientWidth !== this.width) {
this.setDimensions();
this.drawAxis(this.bounds, this.timeSystem);
this.updateNowMarker();
Expand All @@ -139,11 +143,10 @@
}
},
setDimensions() {
const axisHolder = this.$refs.axisHolder;
this.width = axisHolder.clientWidth;
this.width = this.axisHolder.clientWidth;
this.offsetWidth = this.width - this.offset;

this.height = Math.round(axisHolder.getBoundingClientRect().height);
this.height = Math.round(this.axisHolder.getBoundingClientRect().height);

if (this.useSVG) {
this.svgElement.attr('width', this.width);
Expand Down
Loading