Open Bug 1302226 Opened 8 years ago Updated 2 years ago

Convert Storage inspector toolbar to HTML

Categories

(DevTools :: Storage Inspector, enhancement, P2)

enhancement

Tracking

(Not tracked)

People

(Reporter: ntim, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
Attached patch Patch (WIP) (obsolete) — Splinter Review
Still need to fix the test.
Attachment #8794141 - Flags: review?(mratcliffe)
Attachment #8794141 - Flags: review?(jsnajdr)
Comment on attachment 8794141 [details] [diff] [review]
Patch (WIP)

Review of attachment 8794141 [details] [diff] [review]:
-----------------------------------------------------------------

::: devtools/client/shared/components/search-box.js
@@ +33,5 @@
> +    });
> +    shortcuts.on(this.props.keyShortcut, (name, event) => {
> +      event.preventDefault();
> +      this.refs.input.focus();
> +    });

The KeyShortcuts object adds a 'keydown' event listener to the window. You need to call shortcuts.destroy() in componentWillUnmount. Otherwise, the listener will leak.

@@ +50,5 @@
> +    this.refs["clear-button"].hidden = !hasValue;
> +    if (hasValue && this.props.hasNoMatch) {
> +      this.refs.input.classList.add("devtools-style-searchbox-no-match");
> +    }
> +  },

You cannot manipulate the DOM elements that are rendered and owned by React. The changes will be overwritten next time React calls "render" and updates the DOM, leading to random bugs.

If the "input" or "clear-button" element has a "filled" class or is hidden or whatever, they must be set on the elements returned from the render() method. The render() method will derive the desired markup from the props and state of the component.

In this case, the SearchBox component should have a state with property "hasValue", which can be changed by calling setState().

@@ +53,5 @@
> +    }
> +  },
> +
> +  onChange() {
> +    this.updateSearchBoxState();

Replace this with:
this.setState({ hasValue: this.refs.input.value.length > 0 });

The rest of the updateSearchBoxState() method will move to render().

@@ +75,5 @@
> +  },
> +
> +  onClearButtonClick() {
> +    this.refs.input.value = "";
> +    this.onChange();

When you change the input.value from a script like this, doesn't the input fire a "change" event? Explicit call to this.onChange() is then not necessary.
Attachment #8794141 - Flags: review?(jsnajdr) → review-
Comment on attachment 8794141 [details] [diff] [review]
Patch (WIP)

Review of attachment 8794141 [details] [diff] [review]:
-----------------------------------------------------------------

::: devtools/client/shared/components/search-box.js
@@ +75,5 @@
> +  },
> +
> +  onClearButtonClick() {
> +    this.refs.input.value = "";
> +    this.onChange();

@jsnajdr: Nope... change events are not triggered when a value is changed programmatically.
Attachment #8794141 - Flags: review?(mratcliffe)
Depends on: 1154789
Attached patch WIP patchSplinter Review
Attachment #8794141 - Attachment is obsolete: true
(In reply to Tim Nguyen :ntim (use needinfo?) from comment #4)
> Created attachment 8800347 [details] [diff] [review]
> WIP patch

Stuff that needs to be done:
- Fix the tests
- Fix the handling of changing hosts
Assignee: ntim.bugs → nobody
Status: ASSIGNED → NEW
The shared search box has been added in bug 1154789 at devtools/client/shared/components/search-box.js
Severity: normal → enhancement
Has Regression Range: --- → irrelevant
Has STR: --- → irrelevant
OS: Unspecified → All
Hardware: Unspecified → All
Product: Firefox → DevTools
Blocks: 1263117
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: