Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Hotels: SummaryRow should use dynamic width to truncate text #1609

Merged
merged 1 commit into from
May 7, 2019

Conversation

RobinCsl
Copy link
Collaborator

@RobinCsl RobinCsl commented May 6, 2019

This fixes #1607

The issue was that using the withDimension HOC meant using the dimensions of the device. On Tablet view, the RoomSummary component is displayed only on half the screen width while SummaryRow assumed there is the full width of the device to render the text. This caused the row to go out of the container if the name of the hotel room was too long on Tablet.

The SummaryRow component was refactored to use two onLayout event listeners so that both the width of the container of the row and the width of the price tag are computed, and the max width for text can be deduced from that.

This fixes #1607

The issue was that using the `withDimension` HOC meant using the dimensions of the device. On Tablet view, the RoomSummary component is displayed only on half the screen width while SummaryRow assumed there is the full width of the device to render the text. This caused the row to go out of the container if the name of the hotel room was too long on Tablet.

The SummaryRow component was refactored to use two onLayout event listeners so that both the width of the container of the row and the width of the price tag are computed, and the max width for text can be deduced from that.
const maxWidth =
containerWidth != null && priceWidth != null
? containerWidth - priceWidth - SPACING
: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it behave correctly when the max width is zero?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the max width to zero just displays the price on the right hand-side, and the text is obviously not showing. That's an acceptable behaviour for me (especially when it should not happen after the Views rendered and executed their onLayout).

Screenshot 2019-05-07 at 09 59 24
Screenshot 2019-05-07 at 10 01 00

@RobinCsl RobinCsl merged commit 0d4fb94 into master May 7, 2019
@RobinCsl RobinCsl deleted the roomsummary-refactor branch May 7, 2019 08:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RoomSummary is not given the right width prop in Tablet mode
2 participants