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

[release/1.x] [table] measureTextContentWithExclusions #2027

Merged
merged 4 commits into from
Jan 26, 2018

Conversation

adidahiya
Copy link
Contributor

@adidahiya adidahiya commented Jan 23, 2018

Motivation

We'd like to add some text to our column headers (column descriptions) which should be shown in the header cell (as an affordance to users that they can click and view more details about the column) but not taken into account for double-click-to-resize interactions on the column.

@adidahiya adidahiya changed the title getComputedStyleWithExclusions [release/1.x] [table] getComputedStyleWithExclusions Jan 23, 2018
// hide all elements to exclude
for (let i = 0; i < elementsToExclude.length; i++) {
const el = elementsToExclude.item(i) as HTMLElement;
el.setAttribute("style", "display: none");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should save off the old style attribute value and set it back to what it was previously.

@blueprint-bot
Copy link

getComputedStyleWithExclusions

Preview: documentation | landing | table

@adidahiya
Copy link
Contributor Author

h/o, this won't work, give me a min

Copy link
Contributor

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

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

Makes sense at a glance. @tgreenwatts didn't you need this recently too?

const elementsToExclude = element.querySelectorAll(`.${CLASSNAME_EXCLUDED_FROM_TEXT_MEASUREMENT}`);

// hide all elements to exclude
for (let i = 0; i < elementsToExclude.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use forEach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can't. it's not an array.

Copy link
Contributor

@gscshoyru gscshoyru left a comment

Choose a reason for hiding this comment

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

Yeah, this makes a basic amount of sense, though kindof wishing there was a better way than just marking something as "ignore me" and hiding it when we calculate.

@adidahiya adidahiya changed the title [release/1.x] [table] getComputedStyleWithExclusions [release/1.x] [table] measureTextContentWithExclusions Jan 23, 2018
@adidahiya
Copy link
Contributor Author

updated to do the "ignore me" part in the right spot

const context = document.createElement("canvas").getContext("2d");
const style = getComputedStyle(element, null);
const style = getComputedStyle(element);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should probably add back the second param

const columnHeaderAndBodyCells = this.tableElement.querySelectorAll(columnCellSelector);
const columnHeaderAndBodyCells = this.tableElement.querySelectorAll(columnCellSelector) as NodeListOf<
HTMLElement
>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change is no longer necessary

@blueprint-bot
Copy link

measureTextContentWithExclusions

Preview: documentation | landing | table

@adidahiya
Copy link
Contributor Author

@giladgray or @themadcreator can I get a quick +1? @tgreenwatts has already tested this and it works

@blueprint-bot
Copy link

undo extra typedef

Preview: documentation | landing | table

@blueprint-bot
Copy link

Update utils.ts

Preview: documentation | landing | table

@adidahiya adidahiya requested a review from rcchen January 26, 2018 17:57
Copy link
Contributor

@rcchen rcchen left a comment

Choose a reason for hiding this comment

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

Did a quick pass, just one quick question

@@ -42,7 +44,7 @@ export const Utils = {
* element's original className and any other classes passed in with variadic
* arguments matching the `classNames` api.
*/
assignClasses<P extends IProps>(elem: React.ReactElement<P>, ...extendedClasses: ClassValue[]) {
assignClasses<P extends IProps>(elem: React.ReactElement<P>, ...extendedClasses: ClassValue[]): React.ReactNode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all the explicit return signatures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find it good hygiene for public-ish APIs. Not entirely relevant to the change at hand.

@adidahiya adidahiya merged commit 243b6c2 into release/1.x Jan 26, 2018
@adidahiya adidahiya deleted the feature/resize-width branch January 26, 2018 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants